From cde501a4543468c402e0623bdb0da34f9f7763f1 Mon Sep 17 00:00:00 2001 From: MinRK Date: Fri, 21 Oct 2011 17:33:24 -0700 Subject: [PATCH] fix --ip='*' argument in various apps It wasn't properly converted to localhost/0.0.0.0 everywhere, causing errors on startup. Fixed in KernelApp, KernelManager (affects QtConsole), and ipcontroller --- IPython/parallel/apps/ipcontrollerapp.py | 16 +++++++++------- IPython/zmq/heartbeat.py | 9 ++++----- IPython/zmq/kernelmanager.py | 3 +++ 3 files changed, 16 insertions(+), 12 deletions(-) diff --git a/IPython/parallel/apps/ipcontrollerapp.py b/IPython/parallel/apps/ipcontrollerapp.py index 90c3da80612..6f28ca439fc 100755 --- a/IPython/parallel/apps/ipcontrollerapp.py +++ b/IPython/parallel/apps/ipcontrollerapp.py @@ -54,7 +54,7 @@ from IPython.parallel.controller.scheduler import TaskScheduler,launch_scheduler from IPython.parallel.controller.sqlitedb import SQLiteDB -from IPython.parallel.util import signal_children, split_url, asbytes +from IPython.parallel.util import signal_children, split_url, asbytes, disambiguate_url # conditional import of MongoDB backend class @@ -287,13 +287,15 @@ def init_schedulers(self): mq = import_item(str(self.mq_class)) hub = self.factory - # maybe_inproc = 'inproc://monitor' if self.use_threads else self.monitor_url + # disambiguate url, in case of * + monitor_url = disambiguate_url(hub.monitor_url) + # maybe_inproc = 'inproc://monitor' if self.use_threads else monitor_url # IOPub relay (in a Process) q = mq(zmq.PUB, zmq.SUB, zmq.PUB, b'N/A',b'iopub') q.bind_in(hub.client_info['iopub']) q.bind_out(hub.engine_info['iopub']) q.setsockopt_out(zmq.SUBSCRIBE, b'') - q.connect_mon(hub.monitor_url) + q.connect_mon(monitor_url) q.daemon=True children.append(q) @@ -302,7 +304,7 @@ def init_schedulers(self): q.bind_in(hub.client_info['mux']) q.setsockopt_in(zmq.IDENTITY, b'mux') q.bind_out(hub.engine_info['mux']) - q.connect_mon(hub.monitor_url) + q.connect_mon(monitor_url) q.daemon=True children.append(q) @@ -311,7 +313,7 @@ def init_schedulers(self): q.bind_in(hub.client_info['control']) q.setsockopt_in(zmq.IDENTITY, b'control') q.bind_out(hub.engine_info['control']) - q.connect_mon(hub.monitor_url) + q.connect_mon(monitor_url) q.daemon=True children.append(q) try: @@ -326,7 +328,7 @@ def init_schedulers(self): q.bind_in(hub.client_info['task'][1]) q.setsockopt_in(zmq.IDENTITY, b'task') q.bind_out(hub.engine_info['task']) - q.connect_mon(hub.monitor_url) + q.connect_mon(monitor_url) q.daemon=True children.append(q) elif scheme == 'none': @@ -335,7 +337,7 @@ def init_schedulers(self): else: self.log.info("task::using Python %s Task scheduler"%scheme) sargs = (hub.client_info['task'][1], hub.engine_info['task'], - hub.monitor_url, hub.client_info['notification']) + monitor_url, disambiguate_url(hub.client_info['notification'])) kwargs = dict(logname='scheduler', loglevel=self.log_level, log_url = self.log_url, config=dict(self.config)) if 'Process' in self.mq_class: diff --git a/IPython/zmq/heartbeat.py b/IPython/zmq/heartbeat.py index f7a86c803bf..aaa6b768fff 100644 --- a/IPython/zmq/heartbeat.py +++ b/IPython/zmq/heartbeat.py @@ -31,15 +31,14 @@ class Heartbeat(Thread): def __init__(self, context, addr=(LOCALHOST, 0)): Thread.__init__(self) self.context = context - self.addr = addr - self.ip = addr[0] - self.port = addr[1] + self.ip, self.port = addr if self.port == 0: s = socket.socket() - s.bind(self.addr) + # '*' means all interfaces to 0MQ, which is '' to socket.socket + s.bind(('' if self.ip == '*' else self.ip, 0)) self.port = s.getsockname()[1] s.close() - self.addr = (self.ip, self.port) + self.addr = (self.ip, self.port) self.daemon = True def run(self): diff --git a/IPython/zmq/kernelmanager.py b/IPython/zmq/kernelmanager.py index 100176b6352..31bae6762f0 100644 --- a/IPython/zmq/kernelmanager.py +++ b/IPython/zmq/kernelmanager.py @@ -710,6 +710,9 @@ def _context_default(self): # The addresses for the communication channels. connection_file = Unicode('') ip = Unicode(LOCALHOST) + def _ip_changed(self, name, old, new): + if new == '*': + self.ip = '0.0.0.0' shell_port = Int(0) iopub_port = Int(0) stdin_port = Int(0)