-
-
Notifications
You must be signed in to change notification settings - Fork 30.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
multiprocessing calls flush on sys.stdout at exit even if it is None (pythonw) #75985
Comments
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). |
This looks to be a duplicate of https://bugs.python.org/issue28326 |
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. |
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. |
Retested it with a freshly installed 3.6.4 version. Used the following code to test: import sys
import multiprocessing
def foo():
return 'bar'
if __name__ == '__main__':
proc = multiprocessing.Process(target=foo)
proc.start()
proc.join()
with open('process_exit_code.txt', 'w') as f:
f.write(sys.version)
f.write('\nprocess exit code: ')
f.write(str(proc.exitcode)) 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: 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. |
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. |
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! |
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:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: