Show More
@@ -174,7 +174,7 b' class FrontendWidget(HistoryConsoleWidget):' | |||
|
174 | 174 | xreq.complete_reply.disconnect(self._handle_complete_reply) |
|
175 | 175 | xreq.object_info_reply.disconnect(self._handle_object_info_reply) |
|
176 | 176 | |
|
177 |
# Handle the case where the old kernel manager is still |
|
|
177 | # Handle the case where the old kernel manager is still listening. | |
|
178 | 178 | if self._kernel_manager.channels_running: |
|
179 | 179 | self._stopped_channels() |
|
180 | 180 |
@@ -11,7 +11,6 b' from IPython.zmq.kernelmanager import KernelManager, SubSocketChannel, \\' | |||
|
11 | 11 | from util import MetaQObjectHasTraits |
|
12 | 12 | |
|
13 | 13 | |
|
14 | ||
|
15 | 14 | class QtSubSocketChannel(SubSocketChannel, QtCore.QObject): |
|
16 | 15 | |
|
17 | 16 | # Emitted when any message is received. |
@@ -18,8 +18,5 b' class MetaQObjectHasTraits(MetaQObject, MetaHasTraits):' | |||
|
18 | 18 | Using this metaclass allows a class to inherit from both HasTraits and |
|
19 | 19 | QObject. See QtKernelManager for an example. |
|
20 | 20 | """ |
|
21 | ||
|
22 | def __init__(cls, name, bases, dct): | |
|
23 | MetaQObject.__init__(cls, name, bases, dct) | |
|
24 | MetaHasTraits.__init__(cls, name, bases, dct) | |
|
21 | pass | |
|
25 | 22 |
@@ -297,9 +297,11 b' def main():' | |||
|
297 | 297 | parser.add_argument('--ip', type=str, default='127.0.0.1', |
|
298 | 298 | help='set the kernel\'s IP address [default: local]') |
|
299 | 299 | parser.add_argument('--xrep', type=int, metavar='PORT', default=0, |
|
300 |
help='set the XREP |
|
|
300 | help='set the XREP channel port [default: random]') | |
|
301 | 301 | parser.add_argument('--pub', type=int, metavar='PORT', default=0, |
|
302 |
help='set the PUB |
|
|
302 | help='set the PUB channel port [default: random]') | |
|
303 | parser.add_argument('--req', type=int, metavar='PORT', default=0, | |
|
304 | help='set the REQ channel port [default: random]') | |
|
303 | 305 | parser.add_argument('--require-parent', action='store_true', |
|
304 | 306 | help='ensure that this process dies with its parent') |
|
305 | 307 | namespace = parser.parse_args() |
@@ -339,7 +341,7 b' def main():' | |||
|
339 | 341 | # Start the kernel mainloop. |
|
340 | 342 | kernel.start() |
|
341 | 343 | |
|
342 | def launch_kernel(xrep_port=0, pub_port=0, independent=False): | |
|
344 | def launch_kernel(xrep_port=0, pub_port=0, req_port=0, independent=False): | |
|
343 | 345 | """ Launches a localhost kernel, binding to the specified ports. |
|
344 | 346 | |
|
345 | 347 | Parameters |
@@ -348,7 +350,10 b' def launch_kernel(xrep_port=0, pub_port=0, independent=False):' | |||
|
348 | 350 | The port to use for XREP channel. |
|
349 | 351 | |
|
350 | 352 | pub_port : int, optional |
|
351 |
The port to use for the SUB |
|
|
353 | The port to use for the SUB channel. | |
|
354 | ||
|
355 | req_port : int, optional | |
|
356 | The port to use for the REQ (raw input) channel. | |
|
352 | 357 | |
|
353 | 358 | independent : bool, optional (default False) |
|
354 | 359 | If set, the kernel process is guaranteed to survive if this process |
@@ -359,14 +364,15 b' def launch_kernel(xrep_port=0, pub_port=0, independent=False):' | |||
|
359 | 364 | Returns |
|
360 | 365 | ------- |
|
361 | 366 | A tuple of form: |
|
362 |
(kernel_process |
|
|
367 | (kernel_process, xrep_port, pub_port, req_port) | |
|
368 | where kernel_process is a Popen object and the ports are integers. | |
|
363 | 369 | """ |
|
364 | 370 | import socket |
|
365 | 371 | from subprocess import Popen |
|
366 | 372 | |
|
367 | 373 | # Find open ports as necessary. |
|
368 | 374 | ports = [] |
|
369 |
ports_needed = int(xrep_port |
|
|
375 | ports_needed = int(xrep_port <= 0) + int(pub_port <= 0) + int(req_port <= 0) | |
|
370 | 376 | for i in xrange(ports_needed): |
|
371 | 377 | sock = socket.socket() |
|
372 | 378 | sock.bind(('', 0)) |
@@ -379,11 +385,13 b' def launch_kernel(xrep_port=0, pub_port=0, independent=False):' | |||
|
379 | 385 | xrep_port = ports.pop(0) |
|
380 | 386 | if pub_port <= 0: |
|
381 | 387 | pub_port = ports.pop(0) |
|
388 | if req_port <= 0: | |
|
389 | req_port = ports.pop(0) | |
|
382 | 390 | |
|
383 | 391 | # Spawn a kernel. |
|
384 | 392 | command = 'from IPython.zmq.kernel import main; main()' |
|
385 | arguments = [ sys.executable, '-c', command, | |
|
386 |
|
|
|
393 | arguments = [ sys.executable, '-c', command, '--xrep', str(xrep_port), | |
|
394 | '--pub', str(pub_port), '--req', str(req_port) ] | |
|
387 | 395 | |
|
388 | 396 | if independent: |
|
389 | 397 | if sys.platform == 'win32': |
@@ -394,7 +402,7 b' def launch_kernel(xrep_port=0, pub_port=0, independent=False):' | |||
|
394 | 402 | else: |
|
395 | 403 | proc = Popen(arguments + ['--require-parent']) |
|
396 | 404 | |
|
397 | return proc, xrep_port, pub_port | |
|
405 | return proc, xrep_port, pub_port, req_port | |
|
398 | 406 | |
|
399 | 407 | |
|
400 | 408 | if __name__ == '__main__': |
@@ -74,7 +74,8 b' class ZmqSocketChannel(Thread):' | |||
|
74 | 74 | self.context = context |
|
75 | 75 | self.session = session |
|
76 | 76 | if address[1] == 0: |
|
77 |
|
|
|
77 | message = 'The port number for a channel cannot be 0.' | |
|
78 | raise InvalidPortNumber(message) | |
|
78 | 79 | self._address = address |
|
79 | 80 | |
|
80 | 81 | def stop(self): |
@@ -345,7 +346,7 b' class RepSocketChannel(ZmqSocketChannel):' | |||
|
345 | 346 | |
|
346 | 347 | def stop(self): |
|
347 | 348 | self.ioloop.stop() |
|
348 |
super( |
|
|
349 | super(RepSocketChannel, self).stop() | |
|
349 | 350 | |
|
350 | 351 | def on_raw_input(self): |
|
351 | 352 | pass |
General Comments 0
You need to be logged in to leave comments.
Login now