Codebase list python-procrunner / 43b4b82
Avoid using select() on Windows Markus Gerstel 6 years ago
1 changed file(s) with 29 addition(s) and 2 deletion(s). Raw diff Collapse all Expand all
115115 if notify:
116116 notify()
117117
118 self._thread = Thread(target = _thread_write_stream_to_buffer)
118 def _thread_write_stream_to_buffer_windows():
119 line = True
120 while line:
121 line = self._stream.readline()
122 if line:
123 self._buffer.write(line)
124 if output or callback:
125 linedecode = line.decode('utf-8')
126 if output:
127 print(linedecode)
128 if callback:
129 callback(linedecode)
130 self._terminated = True
131 if self._debug:
132 logger.debug("Stream reader terminated")
133 if notify:
134 notify()
135
136 if os.name == "nt":
137 self._thread = Thread(target = _thread_write_stream_to_buffer_windows)
138 else:
139 self._thread = Thread(target = _thread_write_stream_to_buffer)
119140 self._thread.daemon = True
120141 self._thread.start()
121142
266287 if thread_pipe_pool:
267288 # Wait for up to 0.5 seconds or for a signal on a remaining stream,
268289 # which could indicate that the process has terminated.
269 event = thread_pipe_pool[0].poll(0.5)
290 try:
291 event = thread_pipe_pool[0].poll(0.5)
292 except IOError as e:
293 # on Windows this raises "IOError: [Errno 109] The pipe has been ended"
294 # which is for all intents and purposes equivalent to a True return value.
295 if e.errno != 109: raise
296 event = True
270297 if event:
271298 # One-shot, so remove stream and watch remaining streams
272299 thread_pipe_pool.pop(0)