From 37e30af6c0acf72ac7919de6f4346128a5b31a4a 2010-09-14 17:12:06 From: Brian Granger Date: 2010-09-14 17:12:06 Subject: [PATCH] Added a first_reply signal to the heartbeat channel. --- diff --git a/IPython/frontend/qt/kernelmanager.py b/IPython/frontend/qt/kernelmanager.py index 4a8df41..a9e3fbb 100644 --- a/IPython/frontend/qt/kernelmanager.py +++ b/IPython/frontend/qt/kernelmanager.py @@ -3,7 +3,6 @@ # System library imports. from PyQt4 import QtCore -import zmq # IPython imports. from IPython.utils.traitlets import Type @@ -42,11 +41,19 @@ class QtXReqSocketChannel(SocketChannelQObject, XReqSocketChannel): # Emitted when any message is received. message_received = QtCore.pyqtSignal(object) - # Emitted when a reply has been received for the corresponding request type. + # Emitted when a reply has been received for the corresponding request + # type. execute_reply = QtCore.pyqtSignal(object) complete_reply = QtCore.pyqtSignal(object) object_info_reply = QtCore.pyqtSignal(object) + # Emitted when the first reply comes back + first_reply = QtCore.pyqtSignal(object) + + # Used by the first_reply signal logic to determine if a reply is the + # first. + _handlers_called = False + #--------------------------------------------------------------------------- # 'XReqSocketChannel' interface #--------------------------------------------------------------------------- @@ -63,6 +70,16 @@ class QtXReqSocketChannel(SocketChannelQObject, XReqSocketChannel): if signal: signal.emit(msg) + if not self._handlers_called: + self.first_reply.emit() + + self._handlers_called = True + + def reset_first_reply(self): + """ Reset the first_reply signal to fire again on the next reply. + """ + self._handlers_called = False + class QtSubSocketChannel(SocketChannelQObject, SubSocketChannel): diff --git a/IPython/zmq/ipkernel.py b/IPython/zmq/ipkernel.py index 4025f84..d43180f 100755 --- a/IPython/zmq/ipkernel.py +++ b/IPython/zmq/ipkernel.py @@ -98,7 +98,7 @@ class Kernel(Configurable): # Build dict of handlers for message types msg_types = [ 'execute_request', 'complete_request', 'object_info_request', 'history_request', - 'shutdown_request'] + 'connect_request', 'shutdown_request'] self.handlers = {} for msg_type in msg_types: self.handlers[msg_type] = getattr(self, msg_type)