Issue 28326: multiprocessing.Process depends on sys.stdout being open (original) (raw)

Created on 2016-10-01 11:45 by Valentin.Lorentz, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
mp.patch tiagoantao,2016-10-02 04:38 Patch with test case review
Pull Requests
URL Status Linked Edit
PR 1410 closed tiagoantao,2017-05-03 02:29
PR 4073 merged pitrou,2017-10-22 09:06
PR 4075 merged pitrou,2017-10-22 09:46
Messages (8)
msg277807 - (view) Author: ProgVal (Valentin.Lorentz) Date: 2016-10-01 11:45
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 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).
msg277849 - (view) Author: Tiago Antao (tiagoantao) * Date: 2016-10-02 04:38
I made a small patch for this. This is the first time I submit one, so please be careful with this...
msg278271 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2016-10-07 21:37
Patch looks plausible to me. The flush calls definitely need to be guarded.
msg278273 - (view) Author: Tiago Antao (tiagoantao) * Date: 2016-10-07 21:51
This is the first patch that I am submitting. More than willing to do any changes deemed necessary...
msg304713 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2017-10-21 16:57
In , we see that sys.stdout and sys.stderr can sometimes simply be None, so we must check for that too.
msg304737 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2017-10-22 09:40
New changeset daeefd2e049b74340307481112a39f77de0f4769 by Antoine Pitrou in branch 'master': bpo-28326: Fix multiprocessing.Process when stdout and/or stderr is closed or None. (#4073) https://github.com/python/cpython/commit/daeefd2e049b74340307481112a39f77de0f4769
msg304740 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2017-10-22 10:27
New changeset 34ef6da8f5fb03b83268bd35b77fb2183c748b70 by Antoine Pitrou in branch '3.6': [3.6] bpo-28326: Fix multiprocessing.Process when stdout and/or stderr is closed or None. (GH-4073). (#4075) https://github.com/python/cpython/commit/34ef6da8f5fb03b83268bd35b77fb2183c748b70
msg304741 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2017-10-22 10:27
This is now fixed in 3.6 and 3.7. Closing!
History
Date User Action Args
2022-04-11 14:58:37 admin set github: 72513
2018-03-11 18:15:55 pitrou unlink issue31804 superseder
2017-10-22 10:27:53 pitrou set status: open -> closedresolution: fixedmessages: + stage: patch review -> resolved
2017-10-22 10:27:15 pitrou set messages: +
2017-10-22 09:46:42 pitrou set pull_requests: + <pull%5Frequest4045>
2017-10-22 09:40:33 pitrou set messages: +
2017-10-22 09:06:46 pitrou set pull_requests: + <pull%5Frequest4043>
2017-10-21 16:57:54 pitrou set nosy: + pitroumessages: + versions: - Python 3.5
2017-10-20 20:39:55 pitrou link issue31804 superseder
2017-05-03 02:30:29 tiagoantao set versions: + Python 3.6, Python 3.7
2017-05-03 02:29:16 tiagoantao set pull_requests: + <pull%5Frequest1515>
2016-10-07 21:51:14 tiagoantao set messages: +
2016-10-07 21:37:22 terry.reedy set nosy: + terry.reedymessages: + type: behaviorstage: patch review
2016-10-02 04:38:18 tiagoantao set files: + mp.patchnosy: + tiagoantaomessages: + keywords: + patch
2016-10-01 22:47:48 tacocat set nosy: + tacocat
2016-10-01 17:28:22 ned.deily set nosy: + davin
2016-10-01 16:40:35 Mariatta set nosy: + Mariatta
2016-10-01 11:45:34 Valentin.Lorentz create