Skip to content

Commit aa9a572

Browse files
committed
fix: skip DummyThread in leaked-thread check (Python 3.9-3.11 compat)
DummyThread instances (created by Python for foreign threads) raise AssertionError on join() in Python <3.12. Filter them out alongside asyncio threads since they are not leaked by test code.
1 parent 1bf6e06 commit aa9a572

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

tests/conftest.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -309,8 +309,13 @@ def _check_leaked_threads():
309309
if not new_threads:
310310
return
311311

312-
# Filter out asyncio event loop threads (managed by pytest-asyncio, not by us).
313-
new_threads = {t for t in new_threads if not t.name.startswith("asyncio_")}
312+
# Filter out asyncio event loop threads (managed by pytest-asyncio, not by us)
313+
# and DummyThreads (created by Python for foreign threads — cannot be joined).
314+
new_threads = {
315+
t
316+
for t in new_threads
317+
if not t.name.startswith("asyncio_") and not isinstance(t, threading._DummyThread)
318+
}
314319
if not new_threads:
315320
return
316321

0 commit comments

Comments
 (0)