[IPython-dev] interrupting local kernels

Matt Terry matt.terry at gmail.com
Fri Feb 24 02:04:51 EST 2012


I want to be able to interrupt an ipython kernel that is local to my
machine, but not owned by the current process.  I recognize that the
general problem of interrupting a truly remote kernel is a harder
problem and i'm not explicitly not addressing that.  However, I think
interrupting a local kernel is worth having a special case.

All you need to interrupt a local kernel is its pid, so you can send a
SIGINT to the appropriate process.  The only way I can think of to get
that information is to ask the remote kernel (over the shell channel)
to return the output of "os.getpid()".  The kernel might restart and
change pid, so you'd have to poll.  This seems ugly and failure prone.

What you need is
A) the kernel to have a nanny that always knows what the kernel's pid is
or
B) the kernel to communicate its pid someway other than over the shell channel

What about using the heartbeat channel to echo the pid?  To my
understanding, the heart beats even if the kernel is chugging away.
We could have the heartbeat channel return the pid instead of the
uuid, or we could return them both.  Alternatively, we could pid
information in a file in .ipython/somewhere, but that seems
potentially contentious.

-matt



More information about the IPython-dev mailing list