[IPython-dev] crtl+c annotations in zmq terminal for suggestions

MinRK benjaminrk at gmail.com
Tue Sep 13 15:17:45 EDT 2011


2011/9/13 Omar Andrés Zapata Mesa <andresete.chaos at gmail.com>

> hi all.
> Doing some tests in the zmq frontend I find the next things
> from minrk repo  git://github.com/minrk/ipython.git in the branch termzmq
>
> ->open a new kernel but not using
>  ipython/IPython/frontend/zmqterminal/app.py
> just run python -c "from IPython.zmq.ipkernel import main; main()"
>

You can start a kernel with just `ipython kernel`


>
>  python -c "from IPython.zmq.ipkernel import main; main()"
> [IPKernelApp] To connect another client to this kernel, use:
> [IPKernelApp] --existing --shell=49587 --iopub=57815 --stdin=55774
> --hb=33990
>
> if you press crtl+c the kernel output is
> ^CKeyboardInterrupt caught in kernel
> that is right!!
>
> -> open in other console
> python app.py  --existing --shell=49587 --iopub=57815 --stdin=55774
> --hb=33990
>

Also, this can be started with just `ipython zmq ...`


>
> and press crtl+c
> output
>
> KeyboardInterrupt
> ---------------------------------------------------------------------------
> RuntimeError                              Traceback (most recent call last)
> /usr/local/lib/python2.6/dist-packages/IPython/frontend/terminal/interactiveshell.pyc
> in raw_input(self, prompt)
>
>     338
>     339         try:
> --> 340             line =
> raw_input_original(prompt).decode(self.stdin_encoding)
>     341         except ValueError:
>     342             warn("\n********\nYou or a %run:ed script called
> sys.stdin.close()"
>
> /home/omazapa/MyProjects/ipython/IPython/frontend/zmqterminal/app.py in
> handle_sigint(self, *args)
>
>     143         # FIXME: this doesn't work, the kernel just dies every time
>
>     144         self.shell.write('KeyboardInterrupt\n')
> --> 145         self.kernel_manager.interrupt_kernel()
>     146
>     147     def init_code(self):
>
> /usr/local/lib/python2.6/dist-packages/IPython/zmq/kernelmanager.pyc in
> interrupt_kernel(self)
>
>     916                 self.kernel.send_signal(signal.SIGINT)
>     917         else:
> --> 918             raise RuntimeError("Cannot interrupt kernel. No kernel
> is running!")
>
>     919
>     920     def signal_kernel(self, signum):
>
> RuntimeError: Cannot interrupt kernel. No kernel is running!
>
> -> it produces a ugly traceback but the kernel is not die.
> -> any know why is tell me that  No kernel is running? (but the kernel is
> running)
> -> calling ipkernel directly show the next traceback
>

External frontends cannot interrupt the kernel, because they know nothing
about the kernel apart from its zmq ports.  In the long run, we need to
split the existing KernelManager into a thin KernelParent that starts,
interrupts, and restarts, and a KernelClient that is actually used in
frontends to issue commands.  Doing this will allow interrupt and restart
from all frontends, rather than just the owner.

Obviously, the traceback shouldn't happen, but the interrupt behavior in
general in the terminal frontend is quite wrong at the moment, and the
principal part of that code in need of further development.

-MinRK


>
>
> --
> Omar Andres Zapata Mesa
> Head Developer Phenomenology of Fundamental Interactions Group (Gfif)
> http://gfif.udea.edu.co
> Division of computer science Gfif Developers (Gfif Dev)
> http://gfifdev.udea.edu.co
> Systems Engineering Student
> Universidad de Antioquia At Medellin - Colombia
> Usuario Linux  #490962
>
>
> _______________________________________________
> IPython-dev mailing list
> IPython-dev at scipy.org
> http://mail.scipy.org/mailman/listinfo/ipython-dev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ipython-dev/attachments/20110913/d11bae0f/attachment.html>


More information about the IPython-dev mailing list