##// END OF EJS Templates
Reading a line is now correctly implemented in ConsoleWidget.
Reading a line is now correctly implemented in ConsoleWidget.

File last commit:

r2702:472d8423
r2706:8cebcc6a
Show More
kernelmanager.py
150 lines | 5.2 KiB | text/x-python | PythonLexer
epatters
* Added 'started_listening' and 'stopped_listening' signals to QtKernelManager. The FrontendWidget listens for these signals....
r2643 """ Defines a KernelManager that provides signals and slots.
epatters
Initial checkin of Qt kernel manager. Began refactor of FrontendWidget.
r2609 """
# System library imports.
from PyQt4 import QtCore
Brian Granger
Fixed high CPU usage of XREQ channel....
r2695 import zmq
epatters
Initial checkin of Qt kernel manager. Began refactor of FrontendWidget.
r2609
# IPython imports.
epatters
* Refactored KernelManager to use Traitlets and to have its channels as attributes...
r2611 from IPython.zmq.kernelmanager import KernelManager, SubSocketChannel, \
epatters
Initial checkin of Qt kernel manager. Began refactor of FrontendWidget.
r2609 XReqSocketChannel, RepSocketChannel
epatters
* Added 'started_listening' and 'stopped_listening' signals to QtKernelManager. The FrontendWidget listens for these signals....
r2643 from util import MetaQObjectHasTraits
epatters
Initial checkin of Qt kernel manager. Began refactor of FrontendWidget.
r2609
class QtSubSocketChannel(SubSocketChannel, QtCore.QObject):
# Emitted when any message is received.
epatters
* Refactored KernelManager to use Traitlets and to have its channels as attributes...
r2611 message_received = QtCore.pyqtSignal(object)
epatters
Initial checkin of Qt kernel manager. Began refactor of FrontendWidget.
r2609
# Emitted when a message of type 'pyout' or 'stdout' is received.
epatters
* Refactored KernelManager to use Traitlets and to have its channels as attributes...
r2611 output_received = QtCore.pyqtSignal(object)
epatters
Initial checkin of Qt kernel manager. Began refactor of FrontendWidget.
r2609
# Emitted when a message of type 'pyerr' or 'stderr' is received.
epatters
* Refactored KernelManager to use Traitlets and to have its channels as attributes...
r2611 error_received = QtCore.pyqtSignal(object)
#---------------------------------------------------------------------------
# 'object' interface
#---------------------------------------------------------------------------
def __init__(self, *args, **kw):
""" Reimplemented to ensure that QtCore.QObject is initialized first.
"""
QtCore.QObject.__init__(self)
SubSocketChannel.__init__(self, *args, **kw)
epatters
Initial checkin of Qt kernel manager. Began refactor of FrontendWidget.
r2609
#---------------------------------------------------------------------------
# 'SubSocketChannel' interface
#---------------------------------------------------------------------------
def call_handlers(self, msg):
""" Reimplemented to emit signals instead of making callbacks.
"""
# Emit the generic signal.
self.message_received.emit(msg)
# Emit signals for specialized message types.
msg_type = msg['msg_type']
if msg_type in ('pyout', 'stdout'):
self.output_received.emit(msg)
elif msg_type in ('pyerr', 'stderr'):
self.error_received.emit(msg)
epatters
Added a flush method to the SubSocketChannel. The Qt console frontend now uses this method to ensure that output has been processed before it writes a new prompt.
r2614 def flush(self):
""" Reimplemented to ensure that signals are dispatched immediately.
"""
super(QtSubSocketChannel, self).flush()
QtCore.QCoreApplication.instance().processEvents()
epatters
Initial checkin of Qt kernel manager. Began refactor of FrontendWidget.
r2609
class QtXReqSocketChannel(XReqSocketChannel, QtCore.QObject):
# Emitted when any message is received.
epatters
* Refactored KernelManager to use Traitlets and to have its channels as attributes...
r2611 message_received = QtCore.pyqtSignal(object)
epatters
Initial checkin of Qt kernel manager. Began refactor of FrontendWidget.
r2609
# Emitted when a reply has been received for the corresponding request type.
epatters
* Refactored KernelManager to use Traitlets and to have its channels as attributes...
r2611 execute_reply = QtCore.pyqtSignal(object)
complete_reply = QtCore.pyqtSignal(object)
object_info_reply = QtCore.pyqtSignal(object)
#---------------------------------------------------------------------------
# 'object' interface
#---------------------------------------------------------------------------
def __init__(self, *args, **kw):
""" Reimplemented to ensure that QtCore.QObject is initialized first.
"""
QtCore.QObject.__init__(self)
XReqSocketChannel.__init__(self, *args, **kw)
epatters
Initial checkin of Qt kernel manager. Began refactor of FrontendWidget.
r2609
#---------------------------------------------------------------------------
# 'XReqSocketChannel' interface
#---------------------------------------------------------------------------
def call_handlers(self, msg):
""" Reimplemented to emit signals instead of making callbacks.
"""
# Emit the generic signal.
self.message_received.emit(msg)
# Emit signals for specialized message types.
msg_type = msg['msg_type']
signal = getattr(self, msg_type, None)
if signal:
signal.emit(msg)
class QtRepSocketChannel(RepSocketChannel, QtCore.QObject):
epatters
* Refactored KernelManager to use Traitlets and to have its channels as attributes...
r2611 #---------------------------------------------------------------------------
# 'object' interface
#---------------------------------------------------------------------------
def __init__(self, *args, **kw):
""" Reimplemented to ensure that QtCore.QObject is initialized first.
"""
QtCore.QObject.__init__(self)
RepSocketChannel.__init__(self, *args, **kw)
epatters
* Added 'started_listening' and 'stopped_listening' signals to QtKernelManager. The FrontendWidget listens for these signals....
r2643 class QtKernelManager(KernelManager, QtCore.QObject):
""" A KernelManager that provides signals and slots.
epatters
* Refactored KernelManager to use Traitlets and to have its channels as attributes...
r2611 """
epatters
* Added 'started_listening' and 'stopped_listening' signals to QtKernelManager. The FrontendWidget listens for these signals....
r2643 __metaclass__ = MetaQObjectHasTraits
# Emitted when the kernel manager has started listening.
epatters
Merge branch 'kernelmanager' of git://github.com/ellisonbg/ipython into qtfrontend. Fixed breakage and conflicts from merge....
r2701 started_channels = QtCore.pyqtSignal()
epatters
* Added 'started_listening' and 'stopped_listening' signals to QtKernelManager. The FrontendWidget listens for these signals....
r2643
# Emitted when the kernel manager has stopped listening.
epatters
Merge branch 'kernelmanager' of git://github.com/ellisonbg/ipython into qtfrontend. Fixed breakage and conflicts from merge....
r2701 stopped_channels = QtCore.pyqtSignal()
epatters
* Added 'started_listening' and 'stopped_listening' signals to QtKernelManager. The FrontendWidget listens for these signals....
r2643
# Use Qt-specific channel classes that emit signals.
epatters
* Refactored KernelManager to use Traitlets and to have its channels as attributes...
r2611 sub_channel_class = QtSubSocketChannel
xreq_channel_class = QtXReqSocketChannel
rep_channel_class = QtRepSocketChannel
epatters
* Added 'started_listening' and 'stopped_listening' signals to QtKernelManager. The FrontendWidget listens for these signals....
r2643
#---------------------------------------------------------------------------
epatters
Merge branch 'kernelmanager' of git://github.com/ellisonbg/ipython into qtfrontend. Fixed breakage and conflicts from merge....
r2701 # 'object' interface
#---------------------------------------------------------------------------
def __init__(self, *args, **kw):
""" Reimplemented to ensure that QtCore.QObject is initialized first.
"""
QtCore.QObject.__init__(self)
KernelManager.__init__(self, *args, **kw)
#---------------------------------------------------------------------------
epatters
* Added 'started_listening' and 'stopped_listening' signals to QtKernelManager. The FrontendWidget listens for these signals....
r2643 # 'KernelManager' interface
#---------------------------------------------------------------------------
Brian Granger
Kernel manager is cleaned up and simplified. Still bugs though.
r2699 def start_channels(self):
epatters
* Added 'started_listening' and 'stopped_listening' signals to QtKernelManager. The FrontendWidget listens for these signals....
r2643 """ Reimplemented to emit signal.
"""
Brian Granger
Kernel manager is cleaned up and simplified. Still bugs though.
r2699 super(QtKernelManager, self).start_channels()
epatters
Merge branch 'kernelmanager' of git://github.com/ellisonbg/ipython into qtfrontend. Fixed breakage and conflicts from merge....
r2701 self.started_channels.emit()
epatters
* Added 'started_listening' and 'stopped_listening' signals to QtKernelManager. The FrontendWidget listens for these signals....
r2643
Brian Granger
Kernel manager is cleaned up and simplified. Still bugs though.
r2699 def stop_channels(self):
epatters
* Added 'started_listening' and 'stopped_listening' signals to QtKernelManager. The FrontendWidget listens for these signals....
r2643 """ Reimplemented to emit signal.
"""
Brian Granger
Kernel manager is cleaned up and simplified. Still bugs though.
r2699 super(QtKernelManager, self).stop_channels()
epatters
Merge branch 'kernelmanager' of git://github.com/ellisonbg/ipython into qtfrontend. Fixed breakage and conflicts from merge....
r2701 self.stopped_channels.emit()