IJulia.jl icon indicating copy to clipboard operation
IJulia.jl copied to clipboard

Kernel not being stopped

Open quinnj opened this issue 12 years ago • 15 comments

I've noticed that when I stop using the IJulia notebook and then check running processes that the Julia kernel sticks around. My usage of IJulia typically involves running

ipython3 notebook --profile julia

from the command line, interacting with the notebook through the web interface, and using "Close and Halt" when I'm done with a notebook. Closing the notebook, the "gui" page (where you open new notebooks), or the console where the original command was run don't seem to make a difference in actually shutting down a Julia kernel instance.

Not sure if I'm doing something wrong here or if this is perhaps a windows only thing.

quinnj avatar Nov 06 '13 13:11 quinnj

I see a couple processes still running on Linux, too.

timholy avatar Nov 06 '13 14:11 timholy

If you open up the IPython dashboard (http://localhost:8998), does it say "Shutdown" next to any of the kernels? That would indicate that IPython has not shut them down.

(Did you launch additional Julia processes with addprocs?)

stevengj avatar Nov 06 '13 16:11 stevengj

I was too quick on the last one. If I click shutdown then the julia kernel does shut down; it's only the ipython process that doesn't quit when I close the browser window. I suppose I should stop launching this with an & after the command, then I can use Ctrl-C to stop it.

I guess the places where I've noticed a julia kernel hanging around are cases where it had "crashed," like when I was testing graphics performance on line plots with many points.

timholy avatar Nov 06 '13 16:11 timholy

"Close and halt" should stop the kernels, but not the tornado python process. THere is no way to stop the server from the webfrontend (yet)

Carreau avatar Nov 06 '13 16:11 Carreau

I tried this a few more times and I'm seeing consistent results. Closing the notebook, choosing "Close and halt", clicking "Shutdown" or "Delete" even, none of these result in the Julia kernel being shutdown. The only way I've found to shutdown the kernel is closing the console from which I originally opened the notebook.

quinnj avatar Nov 06 '13 19:11 quinnj

I can't replicate this. Clicking 'Shutdown' from the dashboard seems to reliably close the Julia process (as well as any processes created by running addprocs from the notebook). @karbarcca, is the problem still happening for you?

malmaud avatar Dec 03 '13 17:12 malmaud

Yes, still happening. I haven't had a chance to dig or explore any more, but I still can only kill the julia process by stopping the ipython command line app (no shutdown/close & halt/etc work).

quinnj avatar Dec 03 '13 22:12 quinnj

I ran into this little nugget perusing the IPython source:

FIXME: Shutdown does not work on Windows due to ZMQ errors!

   if now or sys.platform == 'win32':
       if self.has_kernel:
           self._kill_kernel()

quinnj avatar Feb 28 '14 19:02 quinnj

@minrk, can you comment on what is going on in those lines of manager.py?

If those lines apparently only work when the kernel manager and the kernel are the same process, I don't know if there's anything we can do about it in IJulia. Maybe file an IPython issue?

stevengj avatar Feb 28 '14 20:02 stevengj

I don't know what's going on there. Presumably someone saw errors when trying the polite shutdown mechanism on Windows, and gave up on trying to fix it (as is our default pattern on Windows). It may not even be an issue anymore, I will check it out.

minrk avatar Feb 28 '14 20:02 minrk

Thanks @minrk. All of the self.has_kernel conditionals in the kernel manager code might be worth revisiting, since those will never be true for the IJulia kernel.

stevengj avatar Feb 28 '14 20:02 stevengj

Why would has_kernel ever be different for the Julia kernel?

minrk avatar Feb 28 '14 20:02 minrk

I'm not sure if it's the same ZMQ error, but I've noticed in developing my own ZMQ backend for Sublime-IJulia that trying to destroy the ZMQ context seems to error silently. I haven't looked into it a ton, but that's what it made me think of when I saw "ZMQ errors".

quinnj avatar Feb 28 '14 21:02 quinnj

Oh, I thought has_kernel meant that the manager and the kernel were running in the same process; I guess that's not what it means. In which case I don't understand why those lines would work for Python but not for Julia.

stevengj avatar Feb 28 '14 21:02 stevengj

I have the same (a similar?) issue. I haven't tried to pinpoint what behavior causes it, but when I run top, I see seven julia processes, but in the "Running" tab there's only three. It's not new behavior, I just got tired of it this morning and went looking for a fix. Julia 1.0, Linux.

cstjean avatar Sep 24 '18 14:09 cstjean