4

I'm using REPL inside VScode and trying to fix a code that gets stuck inside a certain package. I want to figure out which process is taking time by looking at the stack trace but cannot interrupt because REPL does not respond to ctrl+c. I pressed ctrl+x by accident and that showed ^X on the screen.

I am using JuMP and GLPK so it could be stuck there. However, I am not seeing any outputs.

I would also appreciate any tips on figuring out which process is causing it to be stuck.

user15988
  • 143
  • 2
  • 8
  • What version of the Julia extension are you using? In general, hitting `^C` a bunch of times quickly should force throwing an interrupt. – pfitzseb Feb 02 '21 at 08:37
  • Does any function call a function which is compiled code (of any other language)? I know that, e.g., in MATLAB, -C never reaches down to MEX file content or operations. – Carl Witthoft Feb 03 '21 at 17:36
  • @pfitzseb Is that documented, or just random keyboard bashing on your part? I'm highly skeptical that anything in `julia` responds to a stream of control characters. – Carl Witthoft Feb 03 '21 at 17:37
  • I am using Julia1.4. I still haven't figured out what the problem is, but I got to get away with the code getting stuck by disbanding GLPK and using Gurobi. – user15988 Feb 03 '21 at 21:47
  • @pfitzseb I hit ^C as fast as anyone can imagine but that didn't work – user15988 Feb 03 '21 at 21:52
  • @CarlWitthoft Well, I did implement that feature recently (for the VSCode extension that is), but it's only in the very recent 1.1.15 release. The normal Julia REPL does something similar, see [here](https://github.com/JuliaLang/julia/blob/5327824ec8c452410e2a2f755921764df9344855/src/signals-unix.c#L403) and [here](https://github.com/JuliaLang/julia/blob/eb7618dbfa02147c060b37947c5d8becbb4e76a3/src/signal-handling.c#L47). – pfitzseb Feb 09 '21 at 11:36

2 Answers2

2

Interrupts are not implemented in GLPK.jl. I've opened an issue: https://github.com/jump-dev/GLPK.jl/issues/171 (but it's unlikely to get fixed quickly).

If you're interested in contributing to JuMP, it's a good issue to get started with. You could look at the Gurobi.jl code for how we handle interrupts there as inspiration.

Oscar Dowson
  • 2,395
  • 1
  • 5
  • 13
0

I started out using GLPK.jl and I also found that it would "hang" on large problems. However, I recommend trying the Cbc.jl solver. It has a time limit parameter which will interrupt the solver in a set number of seconds. I found it to produce quality results. (Or you could use Cbc for Dev/QA testing to determine what might be causing the hanging and switch to GLPK for your production runs.)

You can set the time limit using the seconds parameter as follows.

For newer package versions:

model = Model(optimizer_with_attributes(Cbc.Optimizer
                                        ,"seconds" => 60
                                        ,"threads" => 4
                                        ,"loglevel" => 0
                                        ,"ratioGap" => 0.0001))

Or like this for older package versions:

model = Model(with_optimizer(Cbc.Optimizer
                             ,seconds=60
                             ,threads=4
                             ,loglevel=0
                             ,ratioGap=0.0001))