MCPcopy Index your code
hub / github.com/python/cpython / test_wait

Method test_wait

Lib/test/fork_wait.py:51–80  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

49 support.wait_process(cpid, exitcode=exitcode)
50
51 def test_wait(self):
52 for i in range(NUM_THREADS):
53 thread = threading.Thread(target=self.f, args=(i,))
54 thread.start()
55 self.threads.append(thread)
56
57 # busy-loop to wait for threads
58 for _ in support.sleeping_retry(support.SHORT_TIMEOUT):
59 if len(self.alive) >= NUM_THREADS:
60 break
61
62 a = sorted(self.alive.keys())
63 self.assertEqual(a, list(range(NUM_THREADS)))
64
65 prefork_lives = self.alive.copy()
66
67 # Ignore the warning about fork with threads.
68 with warnings.catch_warnings(category=DeprecationWarning,
69 action="ignore"):
70 if (cpid := os.fork()) == 0:
71 # Child
72 time.sleep(LONGSLEEP)
73 n = 0
74 for key in self.alive:
75 if self.alive[key] != prefork_lives[key]:
76 n += 1
77 os._exit(n)
78 else:
79 # Parent
80 self.wait_impl(cpid, exitcode=0)

Callers

nothing calls this directly

Calls 9

startMethod · 0.95
wait_implMethod · 0.95
listClass · 0.85
appendMethod · 0.45
keysMethod · 0.45
assertEqualMethod · 0.45
copyMethod · 0.45
sleepMethod · 0.45
_exitMethod · 0.45

Tested by

no test coverage detected