Skip to content

Close main process copy of pipe when sampling in parallel #3988

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 6 commits into from
Closed
Changes from 1 commit
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
8 changes: 7 additions & 1 deletion pymc3/parallel_sampling.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,9 @@ def __init__(self, draws:int, tune:int, step_method, chain:int, seed, start):
)
try:
self._process.start()
# Close the remote pipe, so that we get notified if the other
# end is closed.
remote_conn.close()
except IOError as e:
# Something may have gone wrong during the fork / spawn
if e.errno == errno.EPIPE:
Expand Down Expand Up @@ -285,7 +288,10 @@ def write_next(self):
self._msg_pipe.send(("write_next",))

def abort(self):
self._msg_pipe.send(("abort",))
try:
self._msg_pipe.send(("abort",))
except BrokenPipeError:
pass

def join(self, timeout=None):
self._process.join(timeout)
Expand Down