Interrupt with Ctrl+c not working


#1

Is there any reason why I can’t interrupt my code with Ctrl+c sometimes?
It doesn’t seem to work with parallel stuff where I can use Ctrl+d to interrupt but in my case it doesn’t work at all.
Added some stuff to my code maybe you have an idea what kind of behavior can cause this.


#2

One case is code with try blocks, this will not interrupt:

for i=1:10
    try
        info(i)
        sleep(1)
    catch err
        warn(err)
    end
end

Which can be fixed by adding

typeof(err) == InterruptException && rethrow(err)


#3

Good to know. I don’t have a try and catch block :confused:
Actually I’m adding a part to my program which runs at the beginning and I can’t break even if the new part finished already, which seems to be super weird to me.


#4

In Julia 0.6 running under Windows 10, I have found that I cannot interrupt with ctrl-C once PyPlot is loaded (e.g., a file with a using PyPlot.plot statement gets executed). Instead, the ctrl-c goes into a queue somewhere, and finally is acted upon when a plot is actually made. I reported this problem here:

https://github.com/JuliaPy/PyPlot.jl/issues/305

but as far as I know the issue is still open.


#5

hmm okay. That seems weird as well.
I think the really strange part in my case that all the new stuff finished and I still can’t interrupt. And I have no weird stuff added in my opinion. No try catch, to extra libraries (besides GLPK) which seems to run normal.


#6

When I am running my code on a (Linux) server from the terminal (most often, parallel code), I cannot kill a stalled Julia (worker) process, either, if I use TERM (terminate) or INT (interrupt). Then, I simply use the HUP (hangup) signal, which is always successful. Not sure though, if this is specific to parallel processes. If that is the case for you, it may be worth keeping in mind.


#7

Well I can kill it via killall julia at anytime but I don’t want to get out of the julia REPL.


#8

Lucky you, then. When I have the problem with some parallel workers, killall --process-group julia does not help me unless I specifically send the HUP signal — that’s why I wanted to write the above message when I saw the CTRL-c key sequence.


#9

Okay that seems totally strange and yeah more annoying then my issue :smiley: