Show More
@@ -31,7 +31,6 b' import glob' | |||||
31 | from io import BytesIO |
|
31 | from io import BytesIO | |
32 | import os |
|
32 | import os | |
33 | import os.path as path |
|
33 | import os.path as path | |
34 | from select import select |
|
|||
35 | import sys |
|
34 | import sys | |
36 | from threading import Thread, Lock, Event |
|
35 | from threading import Thread, Lock, Event | |
37 | import warnings |
|
36 | import warnings | |
@@ -373,11 +372,10 b' class StreamCapturer(Thread):' | |||||
373 | self.started = True |
|
372 | self.started = True | |
374 |
|
373 | |||
375 | while not self.stop.is_set(): |
|
374 | while not self.stop.is_set(): | |
376 |
|
|
375 | chunk = os.read(self.readfd, 1024) | |
377 |
|
376 | |||
378 | if ready: |
|
|||
379 |
|
|
377 | with self.buffer_lock: | |
380 |
|
|
378 | self.buffer.write(chunk) | |
381 |
|
379 | |||
382 | os.close(self.readfd) |
|
380 | os.close(self.readfd) | |
383 | os.close(self.writefd) |
|
381 | os.close(self.writefd) | |
@@ -395,6 +393,15 b' class StreamCapturer(Thread):' | |||||
395 | if not self.started: |
|
393 | if not self.started: | |
396 | self.start() |
|
394 | self.start() | |
397 |
|
395 | |||
|
396 | def halt(self): | |||
|
397 | """Safely stop the thread.""" | |||
|
398 | if not self.started: | |||
|
399 | return | |||
|
400 | ||||
|
401 | self.stop.set() | |||
|
402 | os.write(self.writefd, b'wake up') # Ensure we're not locked in a read() | |||
|
403 | self.join() | |||
|
404 | ||||
398 | class SubprocessStreamCapturePlugin(Plugin): |
|
405 | class SubprocessStreamCapturePlugin(Plugin): | |
399 | name='subprocstreams' |
|
406 | name='subprocstreams' | |
400 | def __init__(self): |
|
407 | def __init__(self): | |
@@ -429,9 +436,7 b' class SubprocessStreamCapturePlugin(Plugin):' | |||||
429 | formatError = formatFailure |
|
436 | formatError = formatFailure | |
430 |
|
437 | |||
431 | def finalize(self, result): |
|
438 | def finalize(self, result): | |
432 |
|
|
439 | self.stream_capturer.halt() | |
433 | self.stream_capturer.stop.set() |
|
|||
434 | self.stream_capturer.join() |
|
|||
435 |
|
440 | |||
436 |
|
441 | |||
437 | def run_iptest(): |
|
442 | def run_iptest(): |
General Comments 0
You need to be logged in to leave comments.
Login now