Skip to content

Commit

Permalink
fix --ip='*' argument in various apps
Browse files Browse the repository at this point in the history
It wasn't properly converted to localhost/0.0.0.0 everywhere, causing errors on startup.

Fixed in KernelApp, KernelManager (affects QtConsole), and ipcontroller
  • Loading branch information
minrk committed Oct 22, 2011
1 parent 0cd2b7a commit cde501a
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 12 deletions.
16 changes: 9 additions & 7 deletions IPython/parallel/apps/ipcontrollerapp.py
Expand Up @@ -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

Expand Down Expand Up @@ -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)

Expand All @@ -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)

Expand All @@ -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:
Expand All @@ -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':
Expand All @@ -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:
Expand Down
9 changes: 4 additions & 5 deletions IPython/zmq/heartbeat.py
Expand Up @@ -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):
Expand Down
3 changes: 3 additions & 0 deletions IPython/zmq/kernelmanager.py
Expand Up @@ -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)
Expand Down

0 comments on commit cde501a

Please sign in to comment.