summaryrefslogtreecommitdiffstats
path: root/Lib/multiprocessing/forkserver.py
diff options
context:
space:
mode:
authorAntoine Pitrou <pitrou@free.fr>2017-06-24 17:22:23 (GMT)
committerGitHub <noreply@github.com>2017-06-24 17:22:23 (GMT)
commit13e96cc596d158b98996db3fa291086ea4afecd9 (patch)
treee5d5abb7f5364b484ca4396ff99986ccac16ed0c /Lib/multiprocessing/forkserver.py
parent0ee32c148119031e19c79359f5c4789ee69fa355 (diff)
downloadcpython-13e96cc596d158b98996db3fa291086ea4afecd9.zip
cpython-13e96cc596d158b98996db3fa291086ea4afecd9.tar.gz
cpython-13e96cc596d158b98996db3fa291086ea4afecd9.tar.bz2
Fix bpo-30596: Add close() method to multiprocessing.Process (#2010)
* Fix bpo-30596: Add close() method to multiprocessing.Process * Raise ValueError if close() is called before the Process is finished running * Add docs * Add NEWS blurb
Diffstat (limited to 'Lib/multiprocessing/forkserver.py')
-rw-r--r--Lib/multiprocessing/forkserver.py16
1 files changed, 12 insertions, 4 deletions
diff --git a/Lib/multiprocessing/forkserver.py b/Lib/multiprocessing/forkserver.py
index 7010515..b9f9b9d 100644
--- a/Lib/multiprocessing/forkserver.py
+++ b/Lib/multiprocessing/forkserver.py
@@ -210,8 +210,12 @@ def main(listener_fd, alive_r, preload, main_path=None, sys_path=None):
else:
assert os.WIFEXITED(sts)
returncode = os.WEXITSTATUS(sts)
- # Write the exit code to the pipe
- write_signed(child_w, returncode)
+ # Send exit code to client process
+ try:
+ write_signed(child_w, returncode)
+ except BrokenPipeError:
+ # client vanished
+ pass
os.close(child_w)
else:
# This shouldn't happen really
@@ -241,8 +245,12 @@ def main(listener_fd, alive_r, preload, main_path=None, sys_path=None):
finally:
os._exit(code)
else:
- # Send pid to client processes
- write_signed(child_w, pid)
+ # Send pid to client process
+ try:
+ write_signed(child_w, pid)
+ except BrokenPipeError:
+ # client vanished
+ pass
pid_to_fd[pid] = child_w
os.close(child_r)
for fd in fds: