Skip to content

Commit 694c627

Browse files
committed
Refactor test
1 parent 7a5d0b5 commit 694c627

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

Lib/test/test_thread.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -378,20 +378,20 @@ def nop(i, **kwargs):
378378
args=(shared, stop, f"dynamic_{i}", 1000)
379379
thread.start_new_thread(mutator, args)
380380

381-
snt = 32
381+
snt = 16
382382
for i in range(snt):
383383
try:
384384
thread.start_new_thread(nop, (i,), shared)
385385
except RuntimeError:
386386
break
387387

388388
stop.acquire()
389-
self.assertTrue(True, "test done")
390-
# wait for all mutator threads stop.
391389
DELAY = 1.0
392-
wait_t = time.monotonic()
393-
while len(results) < n and time.monotonic() - wait_t < DELAY:
394-
time.sleep(0.001)
390+
# wait for all mutator threads stop.
391+
for _ in support.sleeping_retry(DELAY):
392+
if len(results) == n:
393+
break
394+
self.assertTrue(True, "test successful")
395395

396396

397397
class Barrier:

0 commit comments

Comments
 (0)