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.Process depends on sys.stdout being open #72513
Comments
Hello, The following code: import sys
import multiprocessing
sys.stdout.close()
def foo():
pass
p = multiprocessing.Process(target=foo)
p.start() Crashes with: Traceback (most recent call last):
File "foo.py", line 10, in <module>
p.start()
File "/usr/lib/python3.5/multiprocessing/process.py", line 105, in start
self._popen = self._Popen(self)
File "/usr/lib/python3.5/multiprocessing/context.py", line 212, in _Popen
return _default_context.get_context().Process._Popen(process_obj)
File "/usr/lib/python3.5/multiprocessing/context.py", line 267, in _Popen
return Popen(process_obj)
File "/usr/lib/python3.5/multiprocessing/popen_fork.py", line 17, in __init__
sys.stdout.flush()
ValueError: I/O operation on closed file. This bug has been reported to me on a daemonized program (written prior to PEP-3143). |
I made a small patch for this. This is the first time I submit one, so please be careful with this... |
Patch looks plausible to me. The flush calls definitely need to be guarded. |
This is the first patch that I am submitting. More than willing to do any changes deemed necessary... |
In bpo-31804, we see that sys.stdout and sys.stderr can sometimes simply be None, so we must check for that too. |
This is now fixed in 3.6 and 3.7. Closing! |
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: