Skip to content

Commit 4a75fe7

Browse files
author
Rémy Voet (ryv)
committed
Fix test:
- Redo the change done in test_various_ops because I don't want to change the semantic. - Add a check in test_memory_error_bootstrap to ensure no dangling thread remains.
1 parent 9286aa9 commit 4a75fe7

1 file changed

Lines changed: 9 additions & 5 deletions

File tree

Lib/test/test_threading.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,11 @@ def test_various_ops(self):
215215
self.assertRegex(repr(t), r'^<TestThread\(.*, initial\)>$')
216216
t.start()
217217

218+
if hasattr(threading, 'get_native_id'):
219+
native_ids = set(t.native_id for t in threads) | {threading.get_native_id()}
220+
self.assertNotIn(None, native_ids)
221+
self.assertEqual(len(native_ids), NUMTASKS + 1)
222+
218223
if verbose:
219224
print('waiting for all tasks to complete')
220225
for t in threads:
@@ -224,11 +229,6 @@ def test_various_ops(self):
224229
self.assertIsNotNone(t.ident)
225230
self.assertRegex(repr(t), r'^<TestThread\(.*, stopped -?\d+\)>$')
226231

227-
if hasattr(threading, 'get_native_id'):
228-
native_ids = set(t.native_id for t in threads) | {threading.get_native_id()}
229-
self.assertNotIn(None, native_ids)
230-
self.assertEqual(len(native_ids), NUMTASKS + 1)
231-
232232
if verbose:
233233
print('all tasks done')
234234
self.assertEqual(numrunning.get(), 0)
@@ -1477,11 +1477,15 @@ def _set_ident_memory_error():
14771477
):
14781478
thread.start()
14791479
self.assertFalse(thread.is_alive())
1480+
self.assertFalse(thread in threading._limbo)
1481+
self.assertFalse(thread in threading._active)
14801482

14811483
serving_thread = threading.Thread(target=serving_thread)
14821484
serving_thread.start()
14831485
serving_thread.join(0.1)
14841486
self.assertFalse(serving_thread.is_alive())
1487+
self.assertFalse(serving_thread in threading._limbo)
1488+
self.assertFalse(serving_thread in threading._active)
14851489

14861490

14871491
class ThreadJoinOnShutdown(BaseTestCase):

0 commit comments

Comments
 (0)