diff --git a/IPython/frontend/qt/base_frontend_mixin.py b/IPython/frontend/qt/base_frontend_mixin.py index 2e54e08..02080b7 100644 --- a/IPython/frontend/qt/base_frontend_mixin.py +++ b/IPython/frontend/qt/base_frontend_mixin.py @@ -30,8 +30,8 @@ class BaseFrontendMixin(object): # Disconnect the old kernel manager's channels. old_manager.sub_channel.message_received.disconnect(self._dispatch) - old_manager.xreq_channel.message_received.disconnect(self._dispatch) - old_manager.rep_channel.message_received.disconnect(self._dispatch) + old_manager.shell_channel.message_received.disconnect(self._dispatch) + old_manager.stdin_channel.message_received.disconnect(self._dispatch) old_manager.hb_channel.kernel_died.disconnect( self._handle_kernel_died) @@ -50,8 +50,8 @@ class BaseFrontendMixin(object): # Connect the new kernel manager's channels. kernel_manager.sub_channel.message_received.connect(self._dispatch) - kernel_manager.xreq_channel.message_received.connect(self._dispatch) - kernel_manager.rep_channel.message_received.connect(self._dispatch) + kernel_manager.shell_channel.message_received.connect(self._dispatch) + kernel_manager.stdin_channel.message_received.connect(self._dispatch) kernel_manager.hb_channel.kernel_died.connect(self._handle_kernel_died) # Handle the case where the kernel manager started channels before diff --git a/IPython/frontend/qt/console/frontend_widget.py b/IPython/frontend/qt/console/frontend_widget.py index 966864b..9b6b6df 100644 --- a/IPython/frontend/qt/console/frontend_widget.py +++ b/IPython/frontend/qt/console/frontend_widget.py @@ -184,7 +184,7 @@ class FrontendWidget(HistoryConsoleWidget, BaseFrontendMixin): See parent class :meth:`execute` docstring for full details. """ - msg_id = self.kernel_manager.xreq_channel.execute(source, hidden) + msg_id = self.kernel_manager.shell_channel.execute(source, hidden) self._request_info['execute'] = self._ExecutionRequest(msg_id, 'user') self._hidden = hidden if not hidden: @@ -330,7 +330,7 @@ class FrontendWidget(HistoryConsoleWidget, BaseFrontendMixin): self.kernel_manager.sub_channel.flush() def callback(line): - self.kernel_manager.rep_channel.input(line) + self.kernel_manager.stdin_channel.input(line) self._readline(msg['content']['prompt'], callback=callback) def _handle_kernel_died(self, since_last_heartbeat): @@ -527,7 +527,7 @@ class FrontendWidget(HistoryConsoleWidget, BaseFrontendMixin): # Send the metadata request to the kernel name = '.'.join(context) - msg_id = self.kernel_manager.xreq_channel.object_info(name) + msg_id = self.kernel_manager.shell_channel.object_info(name) pos = self._get_cursor().position() self._request_info['call_tip'] = self._CallTipRequest(msg_id, pos) return True @@ -538,7 +538,7 @@ class FrontendWidget(HistoryConsoleWidget, BaseFrontendMixin): context = self._get_context() if context: # Send the completion request to the kernel - msg_id = self.kernel_manager.xreq_channel.complete( + msg_id = self.kernel_manager.shell_channel.complete( '.'.join(context), # text self._get_input_buffer_cursor_line(), # line self._get_input_buffer_cursor_column(), # cursor_pos diff --git a/IPython/frontend/qt/console/ipython_widget.py b/IPython/frontend/qt/console/ipython_widget.py index f04efd7..e2c2255 100644 --- a/IPython/frontend/qt/console/ipython_widget.py +++ b/IPython/frontend/qt/console/ipython_widget.py @@ -222,7 +222,7 @@ class IPythonWidget(FrontendWidget): """ Reimplemented to make a history request. """ super(IPythonWidget, self)._started_channels() - self.kernel_manager.xreq_channel.history(hist_access_type='tail', n=1000) + self.kernel_manager.shell_channel.history(hist_access_type='tail', n=1000) #--------------------------------------------------------------------------- # 'ConsoleWidget' public interface @@ -264,7 +264,7 @@ class IPythonWidget(FrontendWidget): text = '' # Send the completion request to the kernel - msg_id = self.kernel_manager.xreq_channel.complete( + msg_id = self.kernel_manager.shell_channel.complete( text, # text self._get_input_buffer_cursor_line(), # line self._get_input_buffer_cursor_column(), # cursor_pos @@ -315,7 +315,7 @@ class IPythonWidget(FrontendWidget): """ # If a number was not specified, make a prompt number request. if number is None: - msg_id = self.kernel_manager.xreq_channel.execute('', silent=True) + msg_id = self.kernel_manager.shell_channel.execute('', silent=True) info = self._ExecutionRequest(msg_id, 'prompt') self._request_info['execute'] = info return diff --git a/IPython/frontend/qt/console/ipythonqt.py b/IPython/frontend/qt/console/ipythonqt.py index 5fc787b..97d3bf7 100644 --- a/IPython/frontend/qt/console/ipythonqt.py +++ b/IPython/frontend/qt/console/ipythonqt.py @@ -257,9 +257,9 @@ class IPythonQtConsoleApp(BaseIPythonApplication): # Create a KernelManager and start a kernel. self.kernel_manager = QtKernelManager( - xreq_address=(self.ip, self.shell_port), + shell_address=(self.ip, self.shell_port), sub_address=(self.ip, self.iopub_port), - rep_address=(self.ip, self.stdin_port), + stdin_address=(self.ip, self.stdin_port), hb_address=(self.ip, self.hb_port) ) # start the kernel diff --git a/IPython/frontend/qt/kernelmanager.py b/IPython/frontend/qt/kernelmanager.py index 5e362bd..c6a5dde 100644 --- a/IPython/frontend/qt/kernelmanager.py +++ b/IPython/frontend/qt/kernelmanager.py @@ -7,7 +7,7 @@ from IPython.external.qt import QtCore # IPython imports. from IPython.utils.traitlets import Type from IPython.zmq.kernelmanager import KernelManager, SubSocketChannel, \ - XReqSocketChannel, RepSocketChannel, HBSocketChannel + ShellSocketChannel, StdInSocketChannel, HBSocketChannel from util import MetaQObjectHasTraits, SuperQObject @@ -20,7 +20,7 @@ class SocketChannelQObject(SuperQObject): stopped = QtCore.Signal() #--------------------------------------------------------------------------- - # 'ZmqSocketChannel' interface + # 'ZMQSocketChannel' interface #--------------------------------------------------------------------------- def start(self): @@ -36,7 +36,7 @@ class SocketChannelQObject(SuperQObject): self.stopped.emit() -class QtXReqSocketChannel(SocketChannelQObject, XReqSocketChannel): +class QtShellSocketChannel(SocketChannelQObject, ShellSocketChannel): # Emitted when any message is received. message_received = QtCore.Signal(object) @@ -56,7 +56,7 @@ class QtXReqSocketChannel(SocketChannelQObject, XReqSocketChannel): _handlers_called = False #--------------------------------------------------------------------------- - # 'XReqSocketChannel' interface + # 'ShellSocketChannel' interface #--------------------------------------------------------------------------- def call_handlers(self, msg): @@ -76,7 +76,7 @@ class QtXReqSocketChannel(SocketChannelQObject, XReqSocketChannel): self._handlers_called = True #--------------------------------------------------------------------------- - # 'QtXReqSocketChannel' interface + # 'QtShellSocketChannel' interface #--------------------------------------------------------------------------- def reset_first_reply(self): @@ -136,7 +136,7 @@ class QtSubSocketChannel(SocketChannelQObject, SubSocketChannel): QtCore.QCoreApplication.instance().processEvents() -class QtRepSocketChannel(SocketChannelQObject, RepSocketChannel): +class QtStdInSocketChannel(SocketChannelQObject, StdInSocketChannel): # Emitted when any message is received. message_received = QtCore.Signal(object) @@ -145,7 +145,7 @@ class QtRepSocketChannel(SocketChannelQObject, RepSocketChannel): input_requested = QtCore.Signal(object) #--------------------------------------------------------------------------- - # 'RepSocketChannel' interface + # 'StdInSocketChannel' interface #--------------------------------------------------------------------------- def call_handlers(self, msg): @@ -190,8 +190,8 @@ class QtKernelManager(KernelManager, SuperQObject): # Use Qt-specific channel classes that emit signals. sub_channel_class = Type(QtSubSocketChannel) - xreq_channel_class = Type(QtXReqSocketChannel) - rep_channel_class = Type(QtRepSocketChannel) + shell_channel_class = Type(QtShellSocketChannel) + stdin_channel_class = Type(QtStdInSocketChannel) hb_channel_class = Type(QtHBSocketChannel) #--------------------------------------------------------------------------- @@ -203,8 +203,8 @@ class QtKernelManager(KernelManager, SuperQObject): def start_kernel(self, *args, **kw): """ Reimplemented for proper heartbeat management. """ - if self._xreq_channel is not None: - self._xreq_channel.reset_first_reply() + if self._shell_channel is not None: + self._shell_channel.reset_first_reply() super(QtKernelManager, self).start_kernel(*args, **kw) #------ Channel management ------------------------------------------------- @@ -222,13 +222,13 @@ class QtKernelManager(KernelManager, SuperQObject): self.stopped_channels.emit() @property - def xreq_channel(self): + def shell_channel(self): """ Reimplemented for proper heartbeat management. """ - if self._xreq_channel is None: - self._xreq_channel = super(QtKernelManager, self).xreq_channel - self._xreq_channel.first_reply.connect(self._first_reply) - return self._xreq_channel + if self._shell_channel is None: + self._shell_channel = super(QtKernelManager, self).shell_channel + self._shell_channel.first_reply.connect(self._first_reply) + return self._shell_channel #--------------------------------------------------------------------------- # Protected interface diff --git a/IPython/zmq/blockingkernelmanager.py b/IPython/zmq/blockingkernelmanager.py index 1895044..884aed9 100644 --- a/IPython/zmq/blockingkernelmanager.py +++ b/IPython/zmq/blockingkernelmanager.py @@ -21,8 +21,8 @@ from Queue import Queue, Empty from IPython.utils import io from IPython.utils.traitlets import Type -from .kernelmanager import (KernelManager, SubSocketChannel, - XReqSocketChannel, RepSocketChannel, HBSocketChannel) +from .kernelmanager import (KernelManager, SubSocketChannel, HBSocketChannel, + ShellSocketChannel, StdInSocketChannel) #----------------------------------------------------------------------------- # Functions and classes @@ -61,15 +61,15 @@ class BlockingSubSocketChannel(SubSocketChannel): return msgs -class BlockingXReqSocketChannel(XReqSocketChannel): +class BlockingShellSocketChannel(ShellSocketChannel): def __init__(self, context, session, address=None): - super(BlockingXReqSocketChannel, self).__init__(context, session, + super(BlockingShellSocketChannel, self).__init__(context, session, address) self._in_queue = Queue() def call_handlers(self, msg): - #io.rprint('[[XReq]]', msg) # dbg + #io.rprint('[[Shell]]', msg) # dbg self._in_queue.put(msg) def msg_ready(self): @@ -94,7 +94,7 @@ class BlockingXReqSocketChannel(XReqSocketChannel): return msgs -class BlockingRepSocketChannel(RepSocketChannel): +class BlockingStdInSocketChannel(StdInSocketChannel): def call_handlers(self, msg): #io.rprint('[[Rep]]', msg) # dbg @@ -114,8 +114,8 @@ class BlockingHBSocketChannel(HBSocketChannel): class BlockingKernelManager(KernelManager): # The classes to use for the various channels. - xreq_channel_class = Type(BlockingXReqSocketChannel) + shell_channel_class = Type(BlockingShellSocketChannel) sub_channel_class = Type(BlockingSubSocketChannel) - rep_channel_class = Type(BlockingRepSocketChannel) + stdin_channel_class = Type(BlockingStdInSocketChannel) hb_channel_class = Type(BlockingHBSocketChannel) diff --git a/IPython/zmq/kernelmanager.py b/IPython/zmq/kernelmanager.py index 40801f8..6a35efc 100644 --- a/IPython/zmq/kernelmanager.py +++ b/IPython/zmq/kernelmanager.py @@ -77,7 +77,7 @@ def validate_string_dict(dct): # ZMQ Socket Channel classes #----------------------------------------------------------------------------- -class ZmqSocketChannel(Thread): +class ZMQSocketChannel(Thread): """The base class for the channels that use ZMQ sockets. """ context = None @@ -99,7 +99,7 @@ class ZmqSocketChannel(Thread): address : tuple Standard (ip, port) tuple that the kernel is listening on. """ - super(ZmqSocketChannel, self).__init__() + super(ZMQSocketChannel, self).__init__() self.daemon = True self.context = context @@ -173,14 +173,14 @@ class ZmqSocketChannel(Thread): self.ioloop.add_callback(drop_io_state_callback) -class XReqSocketChannel(ZmqSocketChannel): +class ShellSocketChannel(ZMQSocketChannel): """The XREQ channel for issues request/replies to the kernel. """ command_queue = None def __init__(self, context, session, address): - super(XReqSocketChannel, self).__init__(context, session, address) + super(ShellSocketChannel, self).__init__(context, session, address) self.command_queue = Queue() self.ioloop = ioloop.IOLoop() @@ -196,7 +196,7 @@ class XReqSocketChannel(ZmqSocketChannel): def stop(self): self.ioloop.stop() - super(XReqSocketChannel, self).stop() + super(ShellSocketChannel, self).stop() def call_handlers(self, msg): """This method is called in the ioloop thread when a message arrives. @@ -382,7 +382,7 @@ class XReqSocketChannel(ZmqSocketChannel): self.add_io_state(POLLOUT) -class SubSocketChannel(ZmqSocketChannel): +class SubSocketChannel(ZMQSocketChannel): """The SUB channel which listens for messages that the kernel publishes. """ @@ -469,13 +469,13 @@ class SubSocketChannel(ZmqSocketChannel): self._flushed = True -class RepSocketChannel(ZmqSocketChannel): +class StdInSocketChannel(ZMQSocketChannel): """A reply channel to handle raw_input requests that the kernel makes.""" msg_queue = None def __init__(self, context, session, address): - super(RepSocketChannel, self).__init__(context, session, address) + super(StdInSocketChannel, self).__init__(context, session, address) self.ioloop = ioloop.IOLoop() self.msg_queue = Queue() @@ -491,7 +491,7 @@ class RepSocketChannel(ZmqSocketChannel): def stop(self): self.ioloop.stop() - super(RepSocketChannel, self).stop() + super(StdInSocketChannel, self).stop() def call_handlers(self, msg): """This method is called in the ioloop thread when a message arrives. @@ -540,7 +540,7 @@ class RepSocketChannel(ZmqSocketChannel): self.add_io_state(POLLOUT) -class HBSocketChannel(ZmqSocketChannel): +class HBSocketChannel(ZMQSocketChannel): """The heartbeat channel which monitors the kernel heartbeat. Note that the heartbeat channel is paused by default. As long as you start @@ -686,22 +686,22 @@ class KernelManager(HasTraits): kernel = Instance(Popen) # The addresses for the communication channels. - xreq_address = TCPAddress((LOCALHOST, 0)) + shell_address = TCPAddress((LOCALHOST, 0)) sub_address = TCPAddress((LOCALHOST, 0)) - rep_address = TCPAddress((LOCALHOST, 0)) + stdin_address = TCPAddress((LOCALHOST, 0)) hb_address = TCPAddress((LOCALHOST, 0)) # The classes to use for the various channels. - xreq_channel_class = Type(XReqSocketChannel) + shell_channel_class = Type(ShellSocketChannel) sub_channel_class = Type(SubSocketChannel) - rep_channel_class = Type(RepSocketChannel) + stdin_channel_class = Type(StdInSocketChannel) hb_channel_class = Type(HBSocketChannel) # Protected traits. _launch_args = Any - _xreq_channel = Any + _shell_channel = Any _sub_channel = Any - _rep_channel = Any + _stdin_channel = Any _hb_channel = Any def __init__(self, **kwargs): @@ -713,7 +713,7 @@ class KernelManager(HasTraits): # Channel management methods: #-------------------------------------------------------------------------- - def start_channels(self, xreq=True, sub=True, rep=True, hb=True): + def start_channels(self, shell=True, sub=True, stdin=True, hb=True): """Starts the channels for this kernel. This will create the channels if they do not exist and then start @@ -721,32 +721,32 @@ class KernelManager(HasTraits): must first call :method:`start_kernel`. If the channels have been stopped and you call this, :class:`RuntimeError` will be raised. """ - if xreq: - self.xreq_channel.start() + if shell: + self.shell_channel.start() if sub: self.sub_channel.start() - if rep: - self.rep_channel.start() + if stdin: + self.stdin_channel.start() if hb: self.hb_channel.start() def stop_channels(self): """Stops all the running channels for this kernel. """ - if self.xreq_channel.is_alive(): - self.xreq_channel.stop() + if self.shell_channel.is_alive(): + self.shell_channel.stop() if self.sub_channel.is_alive(): self.sub_channel.stop() - if self.rep_channel.is_alive(): - self.rep_channel.stop() + if self.stdin_channel.is_alive(): + self.stdin_channel.stop() if self.hb_channel.is_alive(): self.hb_channel.stop() @property def channels_running(self): """Are any of the channels created and running?""" - return (self.xreq_channel.is_alive() or self.sub_channel.is_alive() or - self.rep_channel.is_alive() or self.hb_channel.is_alive()) + return (self.shell_channel.is_alive() or self.sub_channel.is_alive() or + self.stdin_channel.is_alive() or self.hb_channel.is_alive()) #-------------------------------------------------------------------------- # Kernel process management methods: @@ -766,10 +766,10 @@ class KernelManager(HasTraits): **kw : optional See respective options for IPython and Python kernels. """ - xreq, sub, rep, hb = self.xreq_address, self.sub_address, \ - self.rep_address, self.hb_address - if xreq[0] not in LOCAL_IPS or sub[0] not in LOCAL_IPS or \ - rep[0] not in LOCAL_IPS or hb[0] not in LOCAL_IPS: + shell, sub, stdin, hb = self.shell_address, self.sub_address, \ + self.stdin_address, self.hb_address + if shell[0] not in LOCAL_IPS or sub[0] not in LOCAL_IPS or \ + stdin[0] not in LOCAL_IPS or hb[0] not in LOCAL_IPS: raise RuntimeError("Can only launch a kernel on a local interface. " "Make sure that the '*_address' attributes are " "configured properly. " @@ -782,11 +782,11 @@ class KernelManager(HasTraits): else: from pykernel import launch_kernel self.kernel, xrep, pub, req, _hb = launch_kernel( - shell_port=xreq[1], iopub_port=sub[1], - stdin_port=rep[1], hb_port=hb[1], **kw) - self.xreq_address = (xreq[0], xrep) + shell_port=shell[1], iopub_port=sub[1], + stdin_port=stdin[1], hb_port=hb[1], **kw) + self.shell_address = (shell[0], xrep) self.sub_address = (sub[0], pub) - self.rep_address = (rep[0], req) + self.stdin_address = (stdin[0], req) self.hb_address = (hb[0], _hb) def shutdown_kernel(self, restart=False): @@ -805,7 +805,7 @@ class KernelManager(HasTraits): # Don't send any additional kernel kill messages immediately, to give # the kernel a chance to properly execute shutdown actions. Wait for at # most 1s, checking every 0.1s. - self.xreq_channel.shutdown(restart=restart) + self.shell_channel.shutdown(restart=restart) for i in range(10): if self.is_alive: time.sleep(0.1) @@ -931,13 +931,13 @@ class KernelManager(HasTraits): #-------------------------------------------------------------------------- @property - def xreq_channel(self): + def shell_channel(self): """Get the REQ socket channel object to make requests of the kernel.""" - if self._xreq_channel is None: - self._xreq_channel = self.xreq_channel_class(self.context, + if self._shell_channel is None: + self._shell_channel = self.shell_channel_class(self.context, self.session, - self.xreq_address) - return self._xreq_channel + self.shell_address) + return self._shell_channel @property def sub_channel(self): @@ -949,13 +949,13 @@ class KernelManager(HasTraits): return self._sub_channel @property - def rep_channel(self): + def stdin_channel(self): """Get the REP socket channel object to handle stdin (raw_input).""" - if self._rep_channel is None: - self._rep_channel = self.rep_channel_class(self.context, + if self._stdin_channel is None: + self._stdin_channel = self.stdin_channel_class(self.context, self.session, - self.rep_address) - return self._rep_channel + self.stdin_address) + return self._stdin_channel @property def hb_channel(self): diff --git a/IPython/zmq/tests/test_message_spec.py b/IPython/zmq/tests/test_message_spec.py index 817113f..fbc9d8d 100644 --- a/IPython/zmq/tests/test_message_spec.py +++ b/IPython/zmq/tests/test_message_spec.py @@ -35,6 +35,6 @@ def teardown(): # Actual tests def test_execute(): - KM.xreq_channel.execute(code='x=1') - KM.xreq_channel.execute(code='print 1') + KM.shell_channel.execute(code='x=1') + KM.shell_channel.execute(code='print 1')