-
-
Notifications
You must be signed in to change notification settings - Fork 31.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
bpo-28326: Fixes multiprocessing.Process depends on sys.stdout being open #1410
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,7 +38,7 @@ | |
|
||
import sys | ||
import time | ||
from multiprocessing import Pool, set_start_method | ||
from multiprocessing import Pool, Process, set_start_method | ||
|
||
# We use this __main__ defined function in the map call below in order to | ||
# check that multiprocessing in correctly running the unguarded | ||
|
@@ -65,6 +65,13 @@ def f(x): | |
raise RuntimeError("Timed out waiting for results") | ||
results.sort() | ||
print(start_method, "->", results) | ||
sys.stdout.close() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. While I understand it's practical to do so, it's a bit weird to add your test there, as it doesn't really have anything to do with There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I also wondered about the placement, so I think you should follow Antoine's suggestion. |
||
sys.stderr.close() | ||
process = Process(target=f, args=(1,)) | ||
process.start() | ||
process.join(10) | ||
if process.is_alive(): | ||
raise RuntimeError("Timed out waiting for single process") | ||
""" | ||
|
||
test_source_main_skipped_in_children = """\ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Either change this to
if sys.stdout is not None and not sys.stdout.closed:
or change the entire statement to
and the equivalent for stderr. I slightly prefer the latter (these exceptions should be rare), but if Antoine expresses a preference for the former, use that.