[3.6] bpo-28326: Fix multiprocessing.Process when stdout and/or stderr is closed or None. (GH-4073). (#4075)

* bpo-28326: Fix multiprocessing.Process when stdout and/or stderr is closed or None. (#4073)

(cherry picked from commit daeefd2e04)

* [3.6] bpo-28326: Fix multiprocessing.Process when stdout and/or stderr is closed or None. (GH-4073).
(cherry picked from commit daeefd2e04)
This commit is contained in:
Antoine Pitrou 2017-10-22 12:27:13 +02:00 committed by GitHub
parent 1e78ed6825
commit 34ef6da8f5
3 changed files with 30 additions and 2 deletions

View file

@ -14,8 +14,14 @@ class Popen(object):
method = 'fork'
def __init__(self, process_obj):
sys.stdout.flush()
sys.stderr.flush()
try:
sys.stdout.flush()
except (AttributeError, ValueError):
pass
try:
sys.stderr.flush()
except (AttributeError, ValueError):
pass
self.returncode = None
self._launch(process_obj)