##// END OF EJS Templates
Changing -1=>0 for bind to random ports.
Brian Granger -
Show More
@@ -290,9 +290,9 b' def main():'
290 parser = ArgumentParser()
290 parser = ArgumentParser()
291 parser.add_argument('--ip', type=str, default='127.0.0.1',
291 parser.add_argument('--ip', type=str, default='127.0.0.1',
292 help='set the kernel\'s IP address [default: local]')
292 help='set the kernel\'s IP address [default: local]')
293 parser.add_argument('--xrep', type=int, metavar='PORT', default=-1,
293 parser.add_argument('--xrep', type=int, metavar='PORT', default=0,
294 help='set the XREP Channel port [default: random]')
294 help='set the XREP Channel port [default: random]')
295 parser.add_argument('--pub', type=int, metavar='PORT', default=-1,
295 parser.add_argument('--pub', type=int, metavar='PORT', default=0,
296 help='set the PUB Channel port [default: random]')
296 help='set the PUB Channel port [default: random]')
297 namespace = parser.parse_args()
297 namespace = parser.parse_args()
298
298
@@ -324,7 +324,7 b' def main():'
324 print >>sys.__stdout__, "Use Ctrl-\\ (NOT Ctrl-C!) to terminate."
324 print >>sys.__stdout__, "Use Ctrl-\\ (NOT Ctrl-C!) to terminate."
325 kernel.start()
325 kernel.start()
326
326
327 def launch_kernel(xrep_port=-1, pub_port=-1):
327 def launch_kernel(xrep_port=0, pub_port=0):
328 """ Launches a localhost kernel, binding to the specified ports. For any
328 """ Launches a localhost kernel, binding to the specified ports. For any
329 port that is left unspecified, a port is chosen by the operating system.
329 port that is left unspecified, a port is chosen by the operating system.
330
330
@@ -336,7 +336,7 b' def launch_kernel(xrep_port=-1, pub_port=-1):'
336
336
337 # Find open ports as necessary.
337 # Find open ports as necessary.
338 ports = []
338 ports = []
339 ports_needed = int(xrep_port < 0) + int(pub_port < 0)
339 ports_needed = int(xrep_port == 0) + int(pub_port == 0)
340 for i in xrange(ports_needed):
340 for i in xrange(ports_needed):
341 sock = socket.socket()
341 sock = socket.socket()
342 sock.bind(('', 0))
342 sock.bind(('', 0))
@@ -345,9 +345,9 b' def launch_kernel(xrep_port=-1, pub_port=-1):'
345 port = sock.getsockname()[1]
345 port = sock.getsockname()[1]
346 sock.close()
346 sock.close()
347 ports[i] = port
347 ports[i] = port
348 if xrep_port < 0:
348 if xrep_port == 0:
349 xrep_port = ports.pop()
349 xrep_port = ports.pop()
350 if pub_port < 0:
350 if pub_port == 0:
351 pub_port = ports.pop()
351 pub_port = ports.pop()
352
352
353 # Spawn a kernel.
353 # Spawn a kernel.
@@ -69,7 +69,7 b' class ZmqSocketChannel(Thread):'
69 raise RuntimeError("Cannot set address on a running channel!")
69 raise RuntimeError("Cannot set address on a running channel!")
70 else:
70 else:
71 if address is None:
71 if address is None:
72 address = (LOCALHOST, -1)
72 address = (LOCALHOST, 0)
73 self._address = address
73 self._address = address
74
74
75 address = property(get_address, set_adresss)
75 address = property(get_address, set_adresss)
General Comments 0
You need to be logged in to leave comments. Login now