You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
multiprocessing calls flush on sys.stdout at exit even if it is None (pythonw) #75985
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
assignee=Noneclosed_at=<Date2018-03-11.19:10:52.978>created_at=<Date2017-10-17.14:59:34.932>labels= ['3.7', '3.8', 'type-bug', 'library']
title='multiprocessing calls flush on sys.stdout at exit even if it is None (pythonw)'updated_at=<Date2018-03-11.19:10:52.977>user='https://github.com/poxthegreat'
If you start Python by pythonw then sys.stdout and sys.stderr are set to None. If you also use multiprocessing then when the child process finishes BaseProcess._bootstrap calls sys.stdout.flush() and sys.stderr.flush() finally. This causes the process return code to be not zero (it is 1).
Unfortunately this is NOT a duplicate of https://bugs.python.org/issue28326. That issue is about a closed output stream. In that case sys.stdout and sys.stderr are file like objects which have been closed.
This issue is about sys.stdout and sys.stderr being None! This is because pythonw was used not python.
It is very important to run the script with pythonw, not just with python. This is the content of the resulting process_exit_code.txt file on my machine:
3.6.4 (v3.6.4:d48eceb, Dec 19 2017, 06:04:45) [MSC v.1900 32 bit (Intel)]
process exit code: 1
As it can be seen the problem was not fixed. The process exit code should be 0. By default the new multiprocessing process created uses the same interpreter as the creator process, so it uses pythonw too.
I'm not using Windows, so I'm unable to test using pythonw. You'll have to provide a fix, or someone else will have to.
poxthegreat commented on Jan 12, 2018
poxthegreatmannequin
MannequinAuthor
More actions
I have already uploaded a patch file but it is not in the required format. Also I realize that most of the confusion was because I forgot to provide the OS version. Perhaps it would be good to have a separate field for that.
I will upload a patch as it is described in the developer guide.
New changeset ff5d213 by Antoine Pitrou (Miss Islington (bot)) in branch '3.7': bpo-31804: Fix multiprocessing.Process with broken standard streams (GH-6079) (GH-6080) ff5d213
New changeset 069b8d2 by Antoine Pitrou in branch '3.6':
[3.6] bpo-31804: Fix multiprocessing.Process with broken standard streams (GH-6079) (GH-6081) 069b8d2
This is all fixed in the Python 3 branches now. I won't bother with Python 2 as it has quite a different code structure and backporting would take too much of my time.
Pox TheGreat, thanks for reporting and the initial patch!
Activity
poxthegreat commentedon Oct 17, 2017
If you start Python by pythonw then sys.stdout and sys.stderr are set to None. If you also use multiprocessing then when the child process finishes BaseProcess._bootstrap calls sys.stdout.flush() and sys.stderr.flush() finally. This causes the process return code to be not zero (it is 1).
pitrou commentedon Oct 20, 2017
This looks to be a duplicate of https://bugs.python.org/issue28326
poxthegreat commentedon Jan 9, 2018
Unfortunately this is NOT a duplicate of https://bugs.python.org/issue28326. That issue is about a closed output stream. In that case sys.stdout and sys.stderr are file like objects which have been closed.
This issue is about sys.stdout and sys.stderr being None! This is because pythonw was used not python.
pitrou commentedon Jan 9, 2018
@pox, nevertheless, the fix committed in #4073 should also fix this issue. Do you disagree?
terryjreedy commentedon Jan 9, 2018
Pox, please retest with either 3.6.4 or 3.7.0a3 (or .0a4 when released, soon). Both were released after the merge that should fix this.
poxthegreat commentedon Jan 10, 2018
Retested it with a freshly installed 3.6.4 version. Used the following code to test:
It is very important to run the script with pythonw, not just with python. This is the content of the resulting process_exit_code.txt file on my machine:
3.6.4 (v3.6.4:d48eceb, Dec 19 2017, 06:04:45) [MSC v.1900 32 bit (Intel)]
process exit code: 1
As it can be seen the problem was not fixed. The process exit code should be 0. By default the new multiprocessing process created uses the same interpreter as the creator process, so it uses pythonw too.
pitrou commentedon Jan 10, 2018
I'm not using Windows, so I'm unable to test using pythonw. You'll have to provide a fix, or someone else will have to.
poxthegreat commentedon Jan 12, 2018
I have already uploaded a patch file but it is not in the required format. Also I realize that most of the confusion was because I forgot to provide the OS version. Perhaps it would be good to have a separate field for that.
I will upload a patch as it is described in the developer guide.
pitrou commentedon Mar 11, 2018
New changeset e756f66 by Antoine Pitrou in branch 'master':
bpo-31804: Fix multiprocessing.Process with broken standard streams (bpo-6079)
e756f66
pitrou commentedon Mar 11, 2018
New changeset ff5d213 by Antoine Pitrou (Miss Islington (bot)) in branch '3.7':
bpo-31804: Fix multiprocessing.Process with broken standard streams (GH-6079) (GH-6080)
ff5d213
pitrou commentedon Mar 11, 2018
New changeset 069b8d2 by Antoine Pitrou in branch '3.6':
[3.6] bpo-31804: Fix multiprocessing.Process with broken standard streams (GH-6079) (GH-6081)
069b8d2
pitrou commentedon Mar 11, 2018
This is all fixed in the Python 3 branches now. I won't bother with Python 2 as it has quite a different code structure and backporting would take too much of my time.
Pox TheGreat, thanks for reporting and the initial patch!