From 236118e24f5583e64916b94b02908ba9dfc5893d Mon Sep 17 00:00:00 2001 From: "Nathaniel J. Smith" Date: Tue, 9 Jun 2020 23:05:41 -0700 Subject: [PATCH] Stop leaking a thread in test_race_between_idle_exit_and_job_assignment It can lead to confusion, e.g.: https://github.com/python-trio/trio/issues/1604 --- trio/_core/tests/test_thread_cache.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/trio/_core/tests/test_thread_cache.py b/trio/_core/tests/test_thread_cache.py index 895c1c2e5f..f19ac1d4cc 100644 --- a/trio/_core/tests/test_thread_cache.py +++ b/trio/_core/tests/test_thread_cache.py @@ -2,6 +2,7 @@ import threading from queue import Queue import time +import sys from .tutil import slow from .. import _thread_cache @@ -118,3 +119,9 @@ def release(self): done = threading.Event() tc.start_thread_soon(lambda: None, lambda _: done.set()) done.wait() + # Let's kill the thread we started, so it doesn't hang around until the + # test suite finishes. Doesn't really do any harm, but it can be confusing + # to see it in debug output. This is hacky, and leaves our ThreadCache + # object in an inconsistent state... but it doesn't matter, because we're + # not going to use it again anyway. + tc.start_thread_soon(lambda: None, lambda _: sys.exit())