diff --git a/IPython/frontend/qt/console/frontend_widget.py b/IPython/frontend/qt/console/frontend_widget.py index afaa3e1..929fb27 100644 --- a/IPython/frontend/qt/console/frontend_widget.py +++ b/IPython/frontend/qt/console/frontend_widget.py @@ -174,7 +174,7 @@ class FrontendWidget(HistoryConsoleWidget): xreq.complete_reply.disconnect(self._handle_complete_reply) xreq.object_info_reply.disconnect(self._handle_object_info_reply) - # Handle the case where the old kernel manager is still channels. + # Handle the case where the old kernel manager is still listening. if self._kernel_manager.channels_running: self._stopped_channels() diff --git a/IPython/frontend/qt/kernelmanager.py b/IPython/frontend/qt/kernelmanager.py index 1ae72bf..de05231 100644 --- a/IPython/frontend/qt/kernelmanager.py +++ b/IPython/frontend/qt/kernelmanager.py @@ -11,7 +11,6 @@ from IPython.zmq.kernelmanager import KernelManager, SubSocketChannel, \ from util import MetaQObjectHasTraits - class QtSubSocketChannel(SubSocketChannel, QtCore.QObject): # Emitted when any message is received. diff --git a/IPython/frontend/qt/util.py b/IPython/frontend/qt/util.py index a1dab85..79358d9 100644 --- a/IPython/frontend/qt/util.py +++ b/IPython/frontend/qt/util.py @@ -18,8 +18,5 @@ class MetaQObjectHasTraits(MetaQObject, MetaHasTraits): Using this metaclass allows a class to inherit from both HasTraits and QObject. See QtKernelManager for an example. """ - - def __init__(cls, name, bases, dct): - MetaQObject.__init__(cls, name, bases, dct) - MetaHasTraits.__init__(cls, name, bases, dct) + pass diff --git a/IPython/zmq/kernel.py b/IPython/zmq/kernel.py index 523e7c6..0f3d2c0 100755 --- a/IPython/zmq/kernel.py +++ b/IPython/zmq/kernel.py @@ -297,9 +297,11 @@ def main(): parser.add_argument('--ip', type=str, default='127.0.0.1', help='set the kernel\'s IP address [default: local]') parser.add_argument('--xrep', type=int, metavar='PORT', default=0, - help='set the XREP Channel port [default: random]') + help='set the XREP channel port [default: random]') parser.add_argument('--pub', type=int, metavar='PORT', default=0, - help='set the PUB Channel port [default: random]') + help='set the PUB channel port [default: random]') + parser.add_argument('--req', type=int, metavar='PORT', default=0, + help='set the REQ channel port [default: random]') parser.add_argument('--require-parent', action='store_true', help='ensure that this process dies with its parent') namespace = parser.parse_args() @@ -339,7 +341,7 @@ def main(): # Start the kernel mainloop. kernel.start() -def launch_kernel(xrep_port=0, pub_port=0, independent=False): +def launch_kernel(xrep_port=0, pub_port=0, req_port=0, independent=False): """ Launches a localhost kernel, binding to the specified ports. Parameters @@ -348,7 +350,10 @@ def launch_kernel(xrep_port=0, pub_port=0, independent=False): The port to use for XREP channel. pub_port : int, optional - The port to use for the SUB Channel. + The port to use for the SUB channel. + + req_port : int, optional + The port to use for the REQ (raw input) channel. independent : bool, optional (default False) If set, the kernel process is guaranteed to survive if this process @@ -359,14 +364,15 @@ def launch_kernel(xrep_port=0, pub_port=0, independent=False): Returns ------- A tuple of form: - (kernel_process [Popen], rep_port [int], sub_port [int]) + (kernel_process, xrep_port, pub_port, req_port) + where kernel_process is a Popen object and the ports are integers. """ import socket from subprocess import Popen # Find open ports as necessary. ports = [] - ports_needed = int(xrep_port == 0) + int(pub_port == 0) + ports_needed = int(xrep_port <= 0) + int(pub_port <= 0) + int(req_port <= 0) for i in xrange(ports_needed): sock = socket.socket() sock.bind(('', 0)) @@ -379,11 +385,13 @@ def launch_kernel(xrep_port=0, pub_port=0, independent=False): xrep_port = ports.pop(0) if pub_port <= 0: pub_port = ports.pop(0) + if req_port <= 0: + req_port = ports.pop(0) # Spawn a kernel. command = 'from IPython.zmq.kernel import main; main()' - arguments = [ sys.executable, '-c', command, - '--xrep', str(xrep_port), '--pub', str(pub_port) ] + arguments = [ sys.executable, '-c', command, '--xrep', str(xrep_port), + '--pub', str(pub_port), '--req', str(req_port) ] if independent: if sys.platform == 'win32': @@ -394,7 +402,7 @@ def launch_kernel(xrep_port=0, pub_port=0, independent=False): else: proc = Popen(arguments + ['--require-parent']) - return proc, xrep_port, pub_port + return proc, xrep_port, pub_port, req_port if __name__ == '__main__': diff --git a/IPython/zmq/kernelmanager.py b/IPython/zmq/kernelmanager.py index 7b879e0..e04a624 100644 --- a/IPython/zmq/kernelmanager.py +++ b/IPython/zmq/kernelmanager.py @@ -74,7 +74,8 @@ class ZmqSocketChannel(Thread): self.context = context self.session = session if address[1] == 0: - raise InvalidPortNumber('The port number for a channel cannot be 0.') + message = 'The port number for a channel cannot be 0.' + raise InvalidPortNumber(message) self._address = address def stop(self): @@ -345,7 +346,7 @@ class RepSocketChannel(ZmqSocketChannel): def stop(self): self.ioloop.stop() - super(SubSocketChannel, self).stop() + super(RepSocketChannel, self).stop() def on_raw_input(self): pass