Skip to content

Commit e52abd2

Browse files
committed
Make sure test cleans up and doesn't race.
1 parent 7d1d912 commit e52abd2

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

Lib/test/test_threading.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1604,17 +1604,22 @@ def test_interrupt_main_invalid_signal(self):
16041604
self.assertRaises(ValueError, _thread.interrupt_main, signal.NSIG)
16051605
self.assertRaises(ValueError, _thread.interrupt_main, 1000000)
16061606

1607+
@threading_helper.reap_threads
16071608
def test_can_interrupt_tight_loops(self):
16081609
#Nothing to assert here. It just shouldn't hang.
16091610

16101611
cont = True
1612+
started = False
16111613
def worker():
1614+
nonlocal started
1615+
started = True
16121616
while cont:
16131617
pass
16141618

16151619
t = threading.Thread(target=worker)
16161620
t.start()
1617-
time.sleep(0.1)
1621+
while not started:
1622+
pass
16181623
cont = False
16191624
t.join()
16201625

0 commit comments

Comments
 (0)