◐ Shell
reader mode source ↗
Skip to content
Merged
Changes from all commits
File filter
Conversations
Jump to
Diff view
Apply and reload
Show whitespace
Diff view
Apply and reload
25 changes: 17 additions & 8 deletions Lib/test/fork_wait.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@

import os, sys, time, unittest
import test.support as support
_thread = support.import_module('_thread')

LONGSLEEP = 2
SHORTSLEEP = 0.5
Expand All @@ -20,8 +21,19 @@
class ForkWait(unittest.TestCase):

def setUp(self):
self.alive = {}
self.stop = 0

def f(self, id):
while not self.stop:
Expand All @@ -43,10 +55,11 @@ def wait_impl(self, cpid):
self.assertEqual(spid, cpid)
self.assertEqual(status, 0, "cause = %d, exit = %d" % (status&0xff, status>>8))

@support.reap_threads
def test_wait(self):
for i in range(NUM_THREADS):
_thread.start_new(self.f, (i,))

# busy-loop to wait for threads
deadline = time.monotonic() + 10.0
Expand Down @@ -75,8 +88,4 @@ def test_wait(self):
os._exit(n)
else:
# Parent
try:
self.wait_impl(cpid)
finally:
# Tell threads to die
self.stop = 1
Toggle all file notes Toggle all file annotations