Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kernel runs in background when frontend is killed #221

Open
xuesoso opened this issue Jun 18, 2020 · 1 comment
Open

Kernel runs in background when frontend is killed #221

xuesoso opened this issue Jun 18, 2020 · 1 comment

Comments

@xuesoso
Copy link

xuesoso commented Jun 18, 2020

Hi, I noticed that when I directly close the frontend program that called "jupyter-console" (e.g. my terminal), it leaves the "python -m ipykernel_launcher -f ~/.local/share/jupyter/runtime/kernel-PID.json" running in the background. I would like to kill the kernel session created by "jupyter-console" whenever its host frontend program is killed / closed. Is there any option or configuration where I can achieve that? Thank you!

@xuesoso
Copy link
Author

xuesoso commented Jun 18, 2020

I think I have some clues as to the reason why. First to provide some of the relevant observations:

  1. On a remote machine without interactive login session, killing the parent frontend (e.g. a Tmux session or terminal) hosting the Jupyter console will lead to the expected killing of ipykernel on the background.
  2. On another machine running Manjaro Gnome, killing the parent frontend (e.g. a Tmux session or terminal) will not kill the ipykernel subprocess. I can see that it's still dangling in the background.

Chasing down the rabbit hole, I found additional observations:

  1. "ipykernel/parentpoller.py" : is responsible for continuous monitoring of parent process that spawned ipykernel. "Line 36" makes the assumption that if the parent of orphaned process is killed, its ID gets set to "1", in which case the kernel will exit itself.
    parentpoller_relevant_code
  2. After adding in a line to log the parent process ID, I found that on the Manjaro Gnome machine, the initial parent process ID transfers from the "jupyer-console":
    initial_ppid
    after killing the initial parent process to:
    post_parent_killed_ppid

ppid

A few additional posts suggest that the parent ID of orphaned processes may not be necessarily set to 1 if there are ancestor processes. I will also raise this issue separately on the "ipykernel".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant