Show More
@@ -1,12 +1,7 b'' | |||
|
1 |
""" |
|
|
2 | """ | |
|
1 | """Wrappers for forwarding stdout/stderr over zmq""" | |
|
3 | 2 | |
|
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 | #----------------------------------------------------------------------------- | |
|
3 | # Copyright (c) IPython Development Team. | |
|
4 | # Distributed under the terms of the Modified BSD License. | |
|
10 | 5 | |
|
11 | 6 | import os |
|
12 | 7 | import threading |
@@ -15,6 +10,7 b' import uuid' | |||
|
15 | 10 | from io import StringIO, UnsupportedOperation |
|
16 | 11 | |
|
17 | 12 | import zmq |
|
13 | from zmq.eventloop.ioloop import IOLoop | |
|
18 | 14 | |
|
19 | 15 | from .session import extract_header |
|
20 | 16 | |
@@ -130,6 +126,17 b' class OutStream(object):' | |||
|
130 | 126 | else: |
|
131 | 127 | break |
|
132 | 128 | |
|
129 | def _schedule_flush(self): | |
|
130 | """schedule a flush in the main thread | |
|
131 | ||
|
132 | only works with a tornado/pyzmq eventloop running | |
|
133 | """ | |
|
134 | if IOLoop.initialized(): | |
|
135 | IOLoop.instance().add_callback(self.flush) | |
|
136 | else: | |
|
137 | # no async loop, at least force the timer | |
|
138 | self._start = 0 | |
|
139 | ||
|
133 | 140 | def flush(self): |
|
134 | 141 | """trigger actual zmq send""" |
|
135 | 142 | if self.pub_socket is None: |
@@ -140,9 +147,9 b' class OutStream(object):' | |||
|
140 | 147 | if mp_mode != CHILD: |
|
141 | 148 | # we are master |
|
142 | 149 | if not self._is_master_thread(): |
|
143 | # sub-threads must not trigger flush, | |
|
144 | # but at least they can force the timer. | |
|
145 |
self._s |
|
|
150 | # sub-threads must not trigger flush directly, | |
|
151 | # but at least they can schedule an async flush, or force the timer. | |
|
152 | self._schedule_flush() | |
|
146 | 153 | return |
|
147 | 154 | |
|
148 | 155 | self._flush_from_subprocesses() |
General Comments 0
You need to be logged in to leave comments.
Login now