Skip to content

Commit

Permalink
Merge pull request ipython#4691 from minrk/no-localhost
Browse files Browse the repository at this point in the history
subprocess output will be unavailable, but the process will not die.

closes ipython#4689
  • Loading branch information
Carreau committed Dec 18, 2013
2 parents d96ba12 + 37d91de commit e08a633
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions IPython/kernel/zmq/iostream.py
Expand Up @@ -20,6 +20,7 @@

from IPython.utils import py3compat
from IPython.utils.py3compat import unicode_type
from IPython.utils.warn import warn

#-----------------------------------------------------------------------------
# Globals
Expand Down Expand Up @@ -65,7 +66,16 @@ def _setup_pipe_in(self):

self._pipe_in = ctx.socket(zmq.PULL)
self._pipe_in.linger = 0
self._pipe_port = self._pipe_in.bind_to_random_port("tcp://127.0.0.1")
try:
self._pipe_port = self._pipe_in.bind_to_random_port("tcp://127.0.0.1")
except zmq.ZMQError as e:
warn("Couldn't bind IOStream to 127.0.0.1: %s" % e +
"\nsubprocess output will be unavailable."
)
self._pipe_flag = False
self._pipe_in.close()
del self._pipe_in
return
self._pipe_poller = zmq.Poller()
self._pipe_poller.register(self._pipe_in, zmq.POLLIN)

Expand All @@ -89,7 +99,7 @@ def _have_pipe_out(self):
def _check_mp_mode(self):
"""check for forks, and switch to zmq pipeline if necessary"""
if not self._pipe_flag or self._is_master_process():
return MASTER
return MASTER
else:
if not self._have_pipe_out():
self._flush_buffer()
Expand Down

0 comments on commit e08a633

Please sign in to comment.