[IPython-dev] about ipython-zmq

Fernando Perez fperez.net at gmail.com
Sat Jul 24 18:12:51 EDT 2010

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.

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:


already has a kernel launcher prototype with the necessary PID information.

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.



More information about the IPython-dev mailing list