[IPython-dev] about ipython-zmq

Brian Granger ellisonbg at gmail.com
Sun Jul 25 17:38:57 EDT 2010


2010/7/24 Fernando Perez <fperez.net at gmail.com>

> Hi Omar,
>
> 2010/7/24 Omar Andrés Zapata Mesa <andresete.chaos at gmail.com>:
> > .
> > Let's suppose the following code in the prompt:
> > In [1]: for i in range(100000):
> >    ...:     print i
> >    ...:
> > This will take a lot of time to run, and if the user wants to stop the
> > process he will normally do it with ctrl+c.
> > by capturing KeyboardInterrupt i was experimenting with a message sent to
> > the kernel to stop such process, but the kernel hangs until the "for"
> > process is over.
> > The solution I see is to run the kernel processes on a thread. what do
> you
> > think?
>
> No, the kernel will be in a separate process, and what needs to be done is:
>
> 1. capture Ctrl-C in the frontend side with the usual try/except.
>
> 2. Send the Ctrl-C as a signal to the kernel process.
>
>
I think it is a little dangerous to forward Ctrl-C.  When there are two
processes like this I think it is very ambiguous as to what it means.  I
would rather go with a frontend magic:

:kernel 0 kill


> In order to do this, you'll  need to know the PID of the kernel
> process, but Evan has already been making progress in this direction
> so you can benefit from his work.  This code:
>
>
> http://github.com/epatters/ipython/blob/qtfrontend/IPython/zmq/kernel.py#L316
>
> already has a kernel launcher prototype with the necessary PID information.
>
>
Let's start to use the Popen interface of Python 2.6.  It has a terminate
and kill method that gets around the PID stuf in a cross platform manner.


> To send the signal, you can use os.kill  for now.  This has problems
> on Windows, but let's get signal handling working on *nix first and
> once things are in place nicely, we'll look into more general options.
>
> > And another question:
> > What magi commands do you think ipython-zmq should have?
>
> For now don't worry about magics, as they should all happen
> kernel-wise for you.  I'll send an email regarding some ideas about
> magics separately shortly.
>
> Cheers,
>
> f
> _______________________________________________
> IPython-dev mailing list
> IPython-dev at scipy.org
> http://mail.scipy.org/mailman/listinfo/ipython-dev
>



-- 
Brian E. Granger, Ph.D.
Assistant Professor of Physics
Cal Poly State University, San Luis Obispo
bgranger at calpoly.edu
ellisonbg at gmail.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ipython-dev/attachments/20100725/0775628a/attachment.html>


More information about the IPython-dev mailing list