[IPython-User] IPython Qt Console hangs when I use raw_input() in a loop

Alejandro Weinstein alejandro.weinstein@gmail....
Tue Jan 31 14:46:38 CST 2012


Hi:

My IPython Qt Console hangs when I use raw_input() in a loop. I need
to Ctrl-C to break the loop. It hangs in different in a different part
of the loop each time I run the code. The same code works as expected
in a terminal instance of IPython. The following snippet illustrates
the problem. I am running Python 2.7.2, IPython 0.12 in an Ubuntu
11.10 machine.

#######################################
In [1]: d = dict((x,x**2) for x in range(100))

In [2]: for e in d:
   ...:     print e,d[e]
   ...:     raw_input()
   ...:
0 0


1 1


2 4


3 9


4 16


5 25


6 36


7 49


8 64


9 81


10 100


11 121


12 144


13 169


14 196



15 225
---------------------------------------------------------------------------
KeyboardInterrupt                         Traceback (most recent call last)
/home/ajw/.emacs.d/python-mode/<ipython-input-2-0817ff28e28e> in <module>()
      1 for e in d:
      2     print e,d[e]
----> 3     raw_input()
      4

/usr/local/lib/python2.7/dist-packages/IPython/zmq/ipkernel.pyc in
<lambda>(prompt)
    236         # raw_input in the user namespace.

    237         if content.get('allow_stdin', False):
--> 238             raw_input = lambda prompt='':
self._raw_input(prompt, ident, parent)
    239         else:
    240             raw_input = lambda prompt='' : self._no_raw_input()

/usr/local/lib/python2.7/dist-packages/IPython/zmq/ipkernel.pyc in
_raw_input(self, prompt, ident, parent)
    446         while True:
    447             try:
--> 448                 ident, reply = self.session.recv(self.stdin_socket, 0)
    449             except Exception:
    450                 self.log.warn("Invalid Message:", exc_info=True)

/usr/local/lib/python2.7/dist-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.7/dist-packages/zmq/core/socket.so in
zmq.core.socket.Socket.recv_multipart (zmq/core/socket.c:5962)()

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

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

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

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

KeyboardInterrupt:


More information about the IPython-User mailing list