bpo-36888: Add multiprocessing.parent_process() (GH-13247)

This commit is contained in:
Thomas Moreau 2019-05-20 21:37:05 +02:00 committed by Antoine Pitrou
parent 5ae1c84bcd
commit c09a9f56c0
12 changed files with 155 additions and 20 deletions

View file

@ -61,8 +61,12 @@ def _launch(self, process_obj):
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)