Skip to content

ctrl-c/ctrl-break hangs interactive python input from win7 64-bit qtconsole #1322

mwiebe opened this Issue Jan 25, 2012 · 4 comments

5 participants

mwiebe commented Jan 25, 2012

This is probably related to #514, but is unrelated to shell commands. In #481, @cboos mentions a context where ctrl-C hangs, this might be related to that as well. I'm running from the latest master.

If I don't hit ctrl-break, things are normal:

In [1]: raw_input("test: ")

test: testing!
Out[1]: u'testing!'

In [2]: 

but, if I do hit ctrl-break, it freezes:

In [2]: raw_input("test: ")

test: can still edit here, but enter doesn't work after hitting ctrl-C
    [at this point, only the 'restart kernel' command works]
IPython member
fperez commented Jan 25, 2012

This may actually be more of an issue with pyreadline than ipython... @jstenar, does this ring any bells? Do you think it could be on the pyreadline side?

IPython member
jstenar commented Jan 25, 2012

I don't think so. I thought pyreadline wasn't used in the qtconsole.

Even without pyreadline installed enter stops working after pressing ctrl-c at the raw_input prompt.
Ctrl-break doesn't affect things for me. (This is in the qtconsole, python2.7 32-bit, windows 7 64-bit).

IPython member
fperez commented Jan 26, 2012

Sorry @jstenar, I missed the fact that this was on the qtconsole and misinterpreted it.

@m-paradox, I've confirmed the problem on windows, and it does not happen on Linux. I also updated to the current pyside (1.1.0) and pyzmq (2.1.11) and I still see it, so it's either a pyside or pyzmq bug that persists in their most current versions, or in the qtconsole itself.

At this point, I'd like to enlist @minrk and @epatters: any thoughts on what could be going on? On Linux, hitting Ctrl-C during a raw_input produces a traceback:

In [1]: raw_input("test: ")

test: ---------------------------------------------------------------------------
KeyboardInterrupt                         Traceback (most recent call last)
/home/fperez/tmp/junk/<ipython-input-1-3df6ba257b63> in <module>()
----> 1 raw_input("test: ")

/home/fperez/usr/lib/python2.7/site-packages/IPython/zmq/ipkernel.pyc in <lambda>(prompt)
    249         # raw_input in the user namespace.

    250         if content.get('allow_stdin', False):
--> 251             raw_input = lambda prompt='': self._raw_input(prompt, ident, parent)
    252         else:
    253             raw_input = lambda prompt='' : self._no_raw_input()

/home/fperez/usr/lib/python2.7/site-packages/IPython/zmq/ipkernel.pyc in _raw_input(self, prompt, ident, parent)
    459         while True:
    460             try:
--> 461                 ident, reply = self.session.recv(self.stdin_socket, 0)
    462             except Exception:
    463                 self.log.warn("Invalid Message:", exc_info=True)

/home/fperez/usr/lib/python2.7/site-packages/IPython/zmq/session.pyc in recv(self, socket, mode, content, copy)
    629             socket = socket.socket
    630         try:
--> 631             msg_list = socket.recv_multipart(mode)
    632         except zmq.ZMQError as e:
    633             if e.errno == zmq.EAGAIN:

/usr/lib/python2.6/dist-packages/zmq/core/ in zmq.core.socket.Socket.recv_multipart (zmq/core/socket.c:5962)()

/usr/lib/python2.6/dist-packages/zmq/core/ in zmq.core.socket.Socket.recv (zmq/core/socket.c:5596)()

/usr/lib/python2.6/dist-packages/zmq/core/ in zmq.core.socket.Socket.recv (zmq/core/socket.c:5471)()

/usr/lib/python2.6/dist-packages/zmq/core/ in zmq.core.socket._recv_copy (zmq/core/socket.c:1567)()

/usr/lib/python2.6/dist-packages/zmq/core/ in zmq.core.error.ZMQError.__init__ (zmq/core/error.c:910)()


In [2]: 

that seems pretty sensible. Traceback, then back to normal (we could perhaps catch these and present them more compactly but still, they are technically correct). On Windows, I get no traceback and it hangs as stated above.

What I'm not sure right now is if the problem is coming from zmq or our raw_input/messaging code... Thoughts?


This issue has come up several times for us. Ctrl-c while waiting for raw_input() hangs the kernel. We're piloting a CS intro course in 60 schools and have written iPython into the curriculum as part of the Enthought Canopy distribution. Sorry for bumping without contributing, and thank you!

@minrk minrk removed the prio-high label Jan 14, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.