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
Block until kernel termination after sending a kill signal #2369
Conversation
Technically, there's no way for a process to survive a SIGKILL short of something going zombie in the OS kernel itself. SIGKILL is an un-ignorable, un-handlable signal: the OS won't let you even try to install a handler for it. So if a process survives a SIGKILL it's because the OS kernel couldn't kill it, at that point something is probably really wrong with the system and I'm not sure worrying about the frontend will help much anways. |
Thanks, @fperez, for that useful information. Given that SIGKILL cannot fail under any reasonable circumstances, I think we should merge this. It would nice, though, if another OS X user could confirm the bug and the fix. |
Also, do you know what this does on Windows, or can someone at Enthought test? All I said was posix-specific, the world of signals in windows is a dark unknown to me. |
According to MSDN (http://msdn.microsoft.com/en-us/library/windows/desktop/ms686714(v=vs.85).aspx), |
@@ -894,13 +894,15 @@ def has_kernel(self): | |||
return self.kernel is not None | |||
|
|||
def kill_kernel(self): | |||
""" Kill the running kernel. """ | |||
""" Kill the running kernel. This method blocks until the kernel process |
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.
Trivial note; let's keep the format of docstrings (I'm sure we violate it somewhere, just trying to keep things tidy where we see it) to
Single-line description
<BLANK LINE>
rest of text...
...
...
So this would simply become
Kill the running kernel.
This method blocks until...
The reason is that we can have popups and other tools in the future that summarize things by culling only the first line; for that to work well, the first line must be a complete sentence and not truncate.
Same reason why that approach is the recommended way to write git commit messages (minus the 50-char limit).
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. I really should know better.
Trivial docstring fix, then we can merge. Thanks!! |
Cleaned up the docstrings. |
Great, merging now, thanks! |
Block until kernel termination after sending a kill signal. This will make for more robust kernel restarting in the Qt console.
Block until kernel termination after sending a kill signal. This will make for more robust kernel restarting in the Qt console.
As users of the Qt console have probably noticed, restarting the kernel is not as reliable as it ought to be. In some cases, a second restart seems to fix the problem; in other cases, the frontend itself becomes wedged. I am currently investigating these problems.
In trying to reproduce these problems, one thing that I noticed immediately is that restarting the kernel via a kill (rather than a clean shutdown) often fails, at least on OS X. Try this:
now=False
tonow=True
in https://github.com/ipython/ipython/blob/master/IPython/frontend/qt/console/frontend_widget.py#L273Usually, I get the following traceback in the frontend process:
Now, this error is quite obscure and I don't really understand what is going on here, but I think the problem is that the new kernel is sometimes started before the old kernel has actually terminated. In any event, waiting for the kernel to terminate before continuing seems to fix the problem.
My only concern with this PR is that blocking calls without timeouts make me a little nervous. If, for some reason, the kernel survives SIGKILL, the frontend application will deadlock. Is this a reasonable concern in practice?