Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions capturer/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,10 @@ class MultiProcessHelper(object):
def __init__(self):
"""Initialize a :class:`MultiProcessHelper` object."""
self.processes = []
try:
self.context = multiprocessing.get_context('fork')
except ValueError:
self.context = multiprocessing.get_context()

def start_child(self, target):
"""
Expand All @@ -146,8 +150,8 @@ def start_child(self, target):
:class:`multiprocessing.Event` to be set when the child
process has finished initialization.
"""
started_event = multiprocessing.Event()
child_process = multiprocessing.Process(target=target, args=(started_event,))
started_event = self.context.Event()
child_process = self.context.Process(target=target, args=(started_event,))
self.processes.append(child_process)
child_process.daemon = True
child_process.start()
Expand Down Expand Up @@ -309,7 +313,7 @@ def start_capture(self):
# Capture (and most likely relay) stdout/stderr as separate streams.
if self.relay:
# Start the subprocess to relay output.
self.output_queue = multiprocessing.Queue()
self.output_queue = self.context.Queue()
self.start_child(self.merge_loop)
else:
# Disable relaying of output.
Expand Down