summaryrefslogtreecommitdiffstats
path: root/Lib/multiprocessing/popen_spawn_posix.py
diff options
context:
space:
mode:
authorThomas Moreau <thomas.moreau.2010@gmail.com>2019-05-20 19:37:05 (GMT)
committerAntoine Pitrou <antoine@python.org>2019-05-20 19:37:05 (GMT)
commitc09a9f56c08d80567454cae6f78f738a89e1ae94 (patch)
tree7f00233cfa994ba74ca952d371ae85651690602a /Lib/multiprocessing/popen_spawn_posix.py
parent5ae1c84bcd13b766989fc3f1e1c851e7bd4c1faa (diff)
downloadcpython-c09a9f56c08d80567454cae6f78f738a89e1ae94.zip
cpython-c09a9f56c08d80567454cae6f78f738a89e1ae94.tar.gz
cpython-c09a9f56c08d80567454cae6f78f738a89e1ae94.tar.bz2
bpo-36888: Add multiprocessing.parent_process() (GH-13247)
Diffstat (limited to 'Lib/multiprocessing/popen_spawn_posix.py')
-rw-r--r--Lib/multiprocessing/popen_spawn_posix.py10
1 files changed, 7 insertions, 3 deletions
diff --git a/Lib/multiprocessing/popen_spawn_posix.py b/Lib/multiprocessing/popen_spawn_posix.py
index 59f8e45..24b8634 100644
--- a/Lib/multiprocessing/popen_spawn_posix.py
+++ b/Lib/multiprocessing/popen_spawn_posix.py
@@ -61,8 +61,12 @@ class Popen(popen_fork.Popen):
with open(parent_w, 'wb', closefd=False) as f:
f.write(fp.getbuffer())
finally:
- if parent_r is not None:
- self.finalizer = util.Finalize(self, os.close, (parent_r,))
- for fd in (child_r, child_w, parent_w):
+ fds_to_close = []
+ for fd in (parent_r, parent_w):
+ if fd is not None:
+ fds_to_close.append(fd)
+ self.finalizer = util.Finalize(self, util.close_fds, fds_to_close)
+
+ for fd in (child_r, child_w):
if fd is not None:
os.close(fd)