Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
daeefd2e
Commit
daeefd2e
authored
Oct 22, 2017
by
Antoine Pitrou
Committed by
GitHub
Oct 22, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bpo-28326: Fix multiprocessing.Process when stdout and/or stderr is closed or None. (#4073)
parent
73c47086
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
30 additions
and
2 deletions
+30
-2
Lib/multiprocessing/popen_fork.py
Lib/multiprocessing/popen_fork.py
+8
-2
Lib/test/_test_multiprocessing.py
Lib/test/_test_multiprocessing.py
+21
-0
Misc/NEWS.d/next/Library/2017-10-22-11-06-02.bpo-28326.rxh7L4.rst
...S.d/next/Library/2017-10-22-11-06-02.bpo-28326.rxh7L4.rst
+1
-0
No files found.
Lib/multiprocessing/popen_fork.py
View file @
daeefd2e
...
...
@@ -14,8 +14,14 @@ class Popen(object):
method
=
'fork'
def
__init__
(
self
,
process_obj
):
sys
.
stdout
.
flush
()
sys
.
stderr
.
flush
()
try
:
sys
.
stdout
.
flush
()
except
(
AttributeError
,
ValueError
):
pass
try
:
sys
.
stderr
.
flush
()
except
(
AttributeError
,
ValueError
):
pass
self
.
returncode
=
None
self
.
finalizer
=
None
self
.
_launch
(
process_obj
)
...
...
Lib/test/_test_multiprocessing.py
View file @
daeefd2e
...
...
@@ -582,6 +582,27 @@ class _TestProcess(BaseTestCase):
proc
.
join
()
self
.
assertTrue
(
evt
.
is_set
())
@
classmethod
def
_test_error_on_stdio_flush
(
self
,
evt
):
evt
.
set
()
def
test_error_on_stdio_flush
(
self
):
streams
=
[
io
.
StringIO
(),
None
]
streams
[
0
].
close
()
for
stream_name
in
(
'stdout'
,
'stderr'
):
for
stream
in
streams
:
old_stream
=
getattr
(
sys
,
stream_name
)
setattr
(
sys
,
stream_name
,
stream
)
try
:
evt
=
self
.
Event
()
proc
=
self
.
Process
(
target
=
self
.
_test_error_on_stdio_flush
,
args
=
(
evt
,))
proc
.
start
()
proc
.
join
()
self
.
assertTrue
(
evt
.
is_set
())
finally
:
setattr
(
sys
,
stream_name
,
old_stream
)
#
#
...
...
Misc/NEWS.d/next/Library/2017-10-22-11-06-02.bpo-28326.rxh7L4.rst
0 → 100644
View file @
daeefd2e
Fix multiprocessing.Process when stdout and/or stderr is closed or None.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment