Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions Lib/test/test_threading.py
Original file line number Diff line number Diff line change
Expand Up @@ -1580,6 +1580,14 @@ def test_3_join_in_forked_from_thread(self):

main_thread = threading.current_thread()
def worker():
# fork() must happen before the interpreter starts shutting
# down: otherwise the main thread is already marked as
# stopped in the parent, the child inherits that state, and
# the test below succeeds without testing anything.
if not main_thread.is_alive():
print('main thread stopped before fork()',
file=sys.stderr, flush=True)
os._exit(3)
childpid = os.fork()
if childpid != 0:
# parent process
Expand All @@ -1595,6 +1603,9 @@ def worker():

w = threading.Thread(target=worker)
w.start()
# Keep the main thread alive until worker() has forked, so that
# the check above cannot be lost to interpreter shutdown.
w.join()
"""
self._run_and_join(script)

Expand Down
Loading