Show More
@@ -1,3 +1,13 b'' | |||||
|
1 | """wrappers for stdout/stderr forwarding over zmq | |||
|
2 | """ | |||
|
3 | ||||
|
4 | #----------------------------------------------------------------------------- | |||
|
5 | # Copyright (C) 2013 The IPython Development Team | |||
|
6 | # | |||
|
7 | # Distributed under the terms of the BSD License. The full license is in | |||
|
8 | # the file COPYING, distributed as part of this software. | |||
|
9 | #----------------------------------------------------------------------------- | |||
|
10 | ||||
1 | import sys |
|
11 | import sys | |
2 | import time |
|
12 | import time | |
3 | import os |
|
13 | import os | |
@@ -7,21 +17,16 b' from io import StringIO' | |||||
7 |
|
17 | |||
8 | import zmq |
|
18 | import zmq | |
9 |
|
19 | |||
10 |
from session import extract_header |
|
20 | from session import extract_header | |
11 |
|
21 | |||
12 | from IPython.utils import io, text |
|
|||
13 | from IPython.utils import py3compat |
|
22 | from IPython.utils import py3compat | |
14 |
|
23 | |||
15 | import multiprocessing as mp |
|
|||
16 | # import multiprocessing.sharedctypes as mpshc |
|
|||
17 | from ctypes import c_bool |
|
|||
18 | #----------------------------------------------------------------------------- |
|
24 | #----------------------------------------------------------------------------- | |
19 | # Globals |
|
25 | # Globals | |
20 | #----------------------------------------------------------------------------- |
|
26 | #----------------------------------------------------------------------------- | |
21 |
|
27 | |||
22 |
MASTER |
|
28 | MASTER = 0 | |
23 | MASTER_WITH_CHILDREN = 1 |
|
29 | CHILD = 1 | |
24 | CHILD = 2 |
|
|||
25 |
|
30 | |||
26 | #----------------------------------------------------------------------------- |
|
31 | #----------------------------------------------------------------------------- | |
27 | # Stream classes |
|
32 | # Stream classes | |
@@ -41,7 +46,6 b' class OutStream(object):' | |||||
41 | self.name = name |
|
46 | self.name = name | |
42 | self.parent_header = {} |
|
47 | self.parent_header = {} | |
43 | self._new_buffer() |
|
48 | self._new_buffer() | |
44 | self._found_newprocess = 0 |
|
|||
45 | self._buffer_lock = threading.Lock() |
|
49 | self._buffer_lock = threading.Lock() | |
46 | self._master_pid = os.getpid() |
|
50 | self._master_pid = os.getpid() | |
47 | self._master_thread = threading.current_thread().ident |
|
51 | self._master_thread = threading.current_thread().ident | |
@@ -81,10 +85,7 b' class OutStream(object):' | |||||
81 | def _check_mp_mode(self): |
|
85 | def _check_mp_mode(self): | |
82 | """check for forks, and switch to zmq pipeline if necessary""" |
|
86 | """check for forks, and switch to zmq pipeline if necessary""" | |
83 | if self._is_master_process(): |
|
87 | if self._is_master_process(): | |
84 | if self._found_newprocess: |
|
88 | return MASTER | |
85 | return MASTER_WITH_CHILDREN |
|
|||
86 | else: |
|
|||
87 | return MASTER_NO_CHILDREN |
|
|||
88 | else: |
|
89 | else: | |
89 | if not self._have_pipe_out(): |
|
90 | if not self._have_pipe_out(): | |
90 | # setup a new out pipe |
|
91 | # setup a new out pipe |
General Comments 0
You need to be logged in to leave comments.
Login now