Skip to content

Commit 40da262

Browse files
committed
Add a test case, and improve the NEWS.d
1 parent c144379 commit 40da262

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

Lib/test/test_thread.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,18 @@ def func():
337337
handle = thread.start_joinable_thread(func, handle=None)
338338
handle.join()
339339

340+
def test_forked_not_started(self):
341+
handle = thread._ThreadHandle()
342+
pid = os.fork()
343+
if pid == 0:
344+
# child process
345+
try:
346+
self.assertTrue(handle.is_alive())
347+
self.assertFalse(handle.is_done())
348+
finally:
349+
os._exit(0)
350+
else:
351+
support.wait_process(pid, exitcode=0)
340352

341353
class Barrier:
342354
def __init__(self, num_threads):
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Improve thread safety in :class:`_PyThread_AfterFork` by preserving not-started handles
1+
Fix :exc:`RuntimeError` when using a not-started :class:`threading.Thread` after calling :func:`os.fork`

0 commit comments

Comments
 (0)