diff options
author | Antoine Pitrou <pitrou@free.fr> | 2018-03-11 19:09:20 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-03-11 19:09:20 (GMT) |
commit | 069b8d20be8018fbd49ed5aaf64c4caba311e48f (patch) | |
tree | 7b6d73f84bde5b2ce5fecd0d3ae4e8edcd075ba3 /Lib/multiprocessing/util.py | |
parent | 20ac11a9fb027f183914bbaaaed091b57c882e54 (diff) | |
download | cpython-069b8d20be8018fbd49ed5aaf64c4caba311e48f.zip cpython-069b8d20be8018fbd49ed5aaf64c4caba311e48f.tar.gz cpython-069b8d20be8018fbd49ed5aaf64c4caba311e48f.tar.bz2 |
[3.6] bpo-31804: Fix multiprocessing.Process with broken standard streams (GH-6079) (GH-6081)
In some conditions the standard streams will be None or closed in the child process (for example if using "pythonw" instead of "python" on Windows). Avoid failing with a non-0 exit code in those conditions.
Report and initial patch by poxthegreat..
(cherry picked from commit e756f66c83786ee82f5f7d45931ae50a6931dd7f)
Diffstat (limited to 'Lib/multiprocessing/util.py')
-rw-r--r-- | Lib/multiprocessing/util.py | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/Lib/multiprocessing/util.py b/Lib/multiprocessing/util.py index b490caa..2457376 100644 --- a/Lib/multiprocessing/util.py +++ b/Lib/multiprocessing/util.py @@ -389,6 +389,20 @@ def _close_stdin(): pass # +# Flush standard streams, if any +# + +def _flush_std_streams(): + try: + sys.stdout.flush() + except (AttributeError, ValueError): + pass + try: + sys.stderr.flush() + except (AttributeError, ValueError): + pass + +# # Start a program with only specified fds kept open # |