@@ -112,7 +112,6 @@ def _check_mp_mode(self):
112112 # setup a new out pipe
113113 self ._setup_pipe_out ()
114114 return CHILD
115-
116115
117116 def start (self ):
118117 """Start the IOPub thread"""
@@ -228,13 +227,6 @@ def __init__(self, session, pub_thread, name, pipe=None):
228227 def _is_master_process (self ):
229228 return os .getpid () == self ._master_pid
230229
231- def _check_mp_mode (self ):
232- """check for forks, and switch to zmq pipeline if necessary"""
233- if self ._is_master_process ():
234- return MASTER
235- else :
236- return CHILD
237-
238230 def set_parent (self , parent ):
239231 self .parent_header = extract_header (parent )
240232
@@ -253,7 +245,9 @@ def _schedule_flush(self):
253245 with self ._flush_lock :
254246 if self ._flush_timeout is not None :
255247 return
256- # non-None to avoid races while waiting for _schedule
248+ # None indicates there's no flush scheduled.
249+ # Use a non-None placeholder to indicate that a flush is scheduled
250+ # to avoid races while we wait for _schedule_in_thread below to fire in the io thread.
257251 self ._flush_timeout = 'placeholder'
258252
259253 # add_timeout has to be handed to the io thread with add_callback
@@ -319,7 +313,7 @@ def write(self, string):
319313 if not isinstance (string , unicode_type ):
320314 string = string .decode (self .encoding , 'replace' )
321315
322- is_child = (self ._check_mp_mode () == CHILD )
316+ is_child = (not self ._is_master_process () )
323317 self ._buffer .write (string )
324318 if is_child :
325319 # newlines imply flush in subprocesses
0 commit comments