Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pdb freezes inside qtconsole #681

Closed
rabbitmcrabbit opened this issue Aug 6, 2011 · 6 comments
Closed

pdb freezes inside qtconsole #681

rabbitmcrabbit opened this issue Aug 6, 2011 · 6 comments
Milestone

Comments

@rabbitmcrabbit
Copy link
Contributor

I'm trying to use pdb.set_trace() inside some code which I'm running in a qtconsole, and it keeps freezing on me during the pdb session. One error message I received was the following:

QTextCursor::setPosition: Position '8680' out of range
QTextCursor::setPosition: Position '8680' out of range
QTextCursor::setPosition: Position '8680' out of range
QTextCursor::setPosition: Position '8680' out of range
Warning: received unknown payload of type 'IPython.zmq.zmqshell.ZMQInteractiveShell.auto_rewrite_input'
Warning: received unknown payload of type 'IPython.zmq.zmqshell.ZMQInteractiveShell.auto_rewrite_input'
Warning: received unknown payload of type 'IPython.zmq.zmqshell.ZMQInteractiveShell.auto_rewrite_input'
Warning: received unknown payload of type 'IPython.zmq.zmqshell.ZMQInteractiveShell.auto_rewrite_input'
Error calling slot "_dispatch" 
---------------------------------------------------------------------------
RuntimeError                                 Python 2.7.1+: /usr/bin/python
                                                   Sat Aug  6 19:02:56 2011
A problem occured executing Python code.  Here is the sequence of function
calls leading up to the error, with the most recent (innermost) call last.
/usr/local/lib/python2.7/dist-packages/IPython/frontend/qt/base_frontend_mixin.pyc in _dispatch(self=, msg={'buffers': [], 'content': {'prompt': '(Pdb) '}, 'header': {'date': datetime.datetime(2011, 8, 6, 19, 2, 56, 518484), 'msg_id': 'edd28288-cd76-4a9b-920a-386bd7339d71', 'msg_type': 'input_request', 'session': 'fda42127-e95e-4d09-bc38-9f1740ecd91f', 'username': 'kernel'}, 'msg_type': 'input_request', 'parent_header': {'date': datetime.datetime(2011, 8, 6, 19, 2, 29, 854983), 'msg_id': '3eaca534-63c3-4dbc-b579-59c9e6358fb1', 'msg_type': 'execute_request', 'session': 'fda8ab1f-5887-403a-ba1e-3a4c28fc5c64', 'username': 'n'}})
     87         """ Called when the KernelManager channels have stopped listening or
     88             when a listening KernelManager is removed from the frontend.
     89         """
     90 
     91     #---------------------------------------------------------------------------
     92     # 'BaseFrontendMixin' protected interface
     93     #---------------------------------------------------------------------------
     94 
     95     def _dispatch(self, msg):
     96         """ Calls the frontend handler associated with the message type of the 
     97             given message.
     98         """
     99         msg_type = msg['msg_type']
    100         handler = getattr(self, '_handle_' + msg_type, None)
    101         if handler:
--> 102             handler(msg)
    103 
    104     def _is_from_this_session(self, msg):
    105         """ Returns whether a reply from the kernel originated from a request
    106             from this frontend.
    107         """
    108         session = self._kernel_manager.session.session
    109         return msg['parent_header']['session'] == session

/usr/local/lib/python2.7/dist-packages/IPython/frontend/qt/console/frontend_widget.pyc in _handle_input_request(self=, msg={'buffers': [], 'content': {'prompt': '(Pdb) '}, 'header': {'date': datetime.datetime(2011, 8, 6, 19, 2, 56, 518484), 'msg_id': 'edd28288-cd76-4a9b-920a-386bd7339d71', 'msg_type': 'input_request', 'session': 'fda42127-e95e-4d09-bc38-9f1740ecd91f', 'username': 'kernel'}, 'msg_type': 'input_request', 'parent_header': {'date': datetime.datetime(2011, 8, 6, 19, 2, 29, 854983), 'msg_id': '3eaca534-63c3-4dbc-b579-59c9e6358fb1', 'msg_type': 'execute_request', 'session': 'fda8ab1f-5887-403a-ba1e-3a4c28fc5c64', 'username': 'n'}})
    316             self._show_interpreter_prompt_for_reply(msg)
    317             self.executed.emit(msg)
    318 
    319     def _handle_input_request(self, msg):
    320         """ Handle requests for raw_input.
    321         """
    322         if self._hidden:
    323             raise RuntimeError('Request for raw input during hidden execution.')
    324 
    325         # Make sure that all output from the SUB channel has been processed
    326         # before entering readline mode.
    327         self.kernel_manager.sub_channel.flush()
    328 
    329         def callback(line):
    330             self.kernel_manager.stdin_channel.input(line)
--> 331         self._readline(msg['content']['prompt'], callback=callback)
    332 
    333     def _handle_kernel_died(self, since_last_heartbeat):
    334         """ Handle the kernel's death by asking if the user wants to restart.
    335         """
    336         if self.custom_restart:
    337             self.custom_restart_kernel_died.emit(since_last_heartbeat)
    338         else:
    339             message = 'The kernel heartbeat has been inactive for %.2f ' \
    340                 'seconds. Do you want to restart the kernel? You may ' \
    341                 'first want to check the network connection.' % \
    342                 since_last_heartbeat
    343             self.restart_kernel(message, now=True)
    344 
    345     def _handle_object_info_reply(self, rep):
    346         """ Handle replies for call tips.

/usr/local/lib/python2.7/dist-packages/IPython/frontend/qt/console/console_widget.pyc in _readline(self=, prompt='(Pdb) ', callback=)
   1658         ----------
   1659         prompt : str, optional
   1660             The prompt to print before reading the line.
   1661 
   1662         callback : callable, optional
   1663             A callback to execute with the read line. If not specified, input is
   1664             read *synchronously* and this method does not return until it has
   1665             been read.
   1666 
   1667         Returns
   1668         -------
   1669         If a callback is specified, returns nothing. Otherwise, returns the
   1670         input string with the trailing newline stripped.
   1671         """
   1672         if self._reading:
-> 1673             raise RuntimeError('Cannot read a line. Widget is already reading.')
   1674 
   1675         if not callback and not self.isVisible():
   1676             # If the user cannot see the widget, this function cannot return.
   1677             raise RuntimeError('Cannot synchronously read a line if the widget '
   1678                                'is not visible!')
   1679 
   1680         self._reading = True
   1681         self._show_prompt(prompt, newline=False)
   1682 
   1683         if callback is None:
   1684             self._reading_callback = None
   1685             while self._reading:
   1686                 QtCore.QCoreApplication.processEvents()
   1687             return self._get_input_buffer(force=True).rstrip('\n')
   1688 

RuntimeError: Cannot read a line. Widget is already reading.

The remainder of the time, I just get the following message:

Warning: received unknown payload of type 'IPython.zmq.zmqshell.ZMQInteractiveShell.auto_rewrite_input'

I haven't quite figured out the pattern yet on where in the pdb session this bug is raised, but it is fatal. I'm running the latest commit (8af0993) on ubuntu 11.04, on python 2.7.1+ (r271:86832).

Happy to provide more info.
Neil

@rabbitmcrabbit
Copy link
Contributor Author

just had it happen again. same error in the terminal. this time, with lots of banging out Ctrl-C in the console, i managed to also yield the error:

/usr/local/lib/python2.7/dist-packages/IPython/zmq/session.py(569)recv()
568 try:
--> 569 msg_list = socket.recv_multipart(mode)
570 except: zmq.ZMQError as e:

(apologies if there are any spelling mistakes there -- i had to type this by hand)

but my Ctrl-C-ing in the end amount to naught, as I had to restart the kernel...

@rabbitmcrabbit
Copy link
Contributor Author

(sorry, didn't mean to close the issue)

I'm not sure if this is a related or separate issue, but after restarting the kernel above by using Ctrl-., the kernel didn't actually successfully restart. Rather, it cleared the window, printed the header, and no prompt ever displayed. This isn't simply a console issue as if I try to connect a new console to the kernel (via --existing etc), the new console does exactly the same thing: it prints the header, but no prompts.

in the meanwhile, i'm getting lots of these in the terminal that launched the original kernel/console:
QTextCursor::setPosition: Position '28808' out of range
QTextCursor::setPosition: Position '28808' out of range
QTextCursor::setPosition: Position '28808' out of range
QTextCursor::setPosition: Position '28808' out of range
QTextCursor::setPosition: Position '28808' out of range

when i look at the terminal during any session, there are heaps of these warnings. i'm running on ubuntu 11.04 if that's useful.

@rabbitmcrabbit
Copy link
Contributor Author

just happened again. pdb is barely functional in qtconsole. this time i have a screenshot of a traceback (the console window is frozen, so i can't copy and paste):

http://postimage.org/image/2wn0gp03o/

@winterstream
Copy link

I have a slightly different problem. pdb works in the QT console but I cannot access the history: neither the up key nor CTRL+up works.

I'm using PySide on OS X Lion.

@rabbitmcrabbit
Copy link
Contributor Author

Yep -- I have the same problem. I raised it in issue #682.

@minrk
Copy link
Member

minrk commented Nov 15, 2011

The 'Widget is already reading' RuntimeError has been fixed in master. It would be caused if the raw_input was interrupted and another raw_input request was made, while the frontend had not yet replied to the first. Now, the frontend interprets all new raw_input requests as superseding any currently active requests and starts over.

Since the various other pdb-in-qt issues have been raised elsewhere (#682, #902), I'm closing this one as fixed.

@minrk minrk closed this as completed Nov 15, 2011
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants