-
-
Notifications
You must be signed in to change notification settings - Fork 367
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
BUG: Kill subprocesses on shutdown. #869
Conversation
Fixes #jupyter/jupyter_client#104 This should make sure we properly cull all subprocesses at shutdown, it does change one of the private method from sync to async in order to no user time.sleep or thread so this may affect subclasses, though I doubt it. It's also not completely clear to me whether this works on windows as SIGINT I belove is not a thing. Regardless as this affects things like dask, and others that are mostly on unix, it should be an improvement. It does the following, stopping as soon as it does not find any more children to current process. - Send sigint to everything - Immediately send sigterm in look with an exponential backoff from 0.01 to 1 second roughtly multiplying the delay until next send by 3 each time. - Switch to sending sigkill with same backoff. There is no delay after sigint, as this is just a courtesy. The delays backoff are not configurable. I can imagine that on slow systems it may make sens
1b53afb
to
b3e8b85
Compare
Co-authored-by: Steven Silvester <[email protected]>
ipykernel/kernelbase.py
Outdated
@@ -1131,9 +1136,62 @@ def _input_request(self, prompt, ident, parent, password=False): | |||
raise EOFError | |||
return value | |||
|
|||
def _at_shutdown(self): | |||
async def _progressively_terminate_all_children(self): | |||
if sys.platform == "win32": |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this method should work on both Windows and Posix: https://stackoverflow.com/a/25134985
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll give it a try. I know that the "loop and kill children" was switched back to killpg
at some point in jupyter_client as the first one had issues.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(that was in jupyter/jupyter_client#743, i'll try to get the same logic from there)
Kicking to make sure we hit all downstream tests |
Weird. I have no idea why the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
Thanks to you for the review and everything. |
Fixes jupyter/jupyter_client#104.
This should make sure we properly cull all subprocesses at shutdown,
it does change one of the private method from sync to async in order to
no user time.sleep or thread so this may affect subclasses, though I
doubt it.
It's also not completely clear to me whether this works on windows as
SIGINT I belove is not a thing.
Regardless as this affects things like dask, and others that are mostly
on unix, it should be an improvement.
It does the following, stopping as soon as it does not find any more
children to current process.
0.01 to 1 second roughtly multiplying the delay until next send by 3
each time.
There is no delay after sigint, as this is just a courtesy.
The delays backoff are not configurable. I can imagine that on slow
systems it may make sens