diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2017-06-30 09:12:33 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-06-30 09:12:33 (GMT) |
commit | b9030674624c181d6e9047cdb14ad65bb6c84c66 (patch) | |
tree | 3f375fb837665a109a98450863f2b51a5fd71d39 /Lib/asyncio | |
parent | 21a0a6c9f8a047b6eb173ee59e38ad5dc3c46f86 (diff) | |
download | cpython-b9030674624c181d6e9047cdb14ad65bb6c84c66.zip cpython-b9030674624c181d6e9047cdb14ad65bb6c84c66.tar.gz cpython-b9030674624c181d6e9047cdb14ad65bb6c84c66.tar.bz2 |
bpo-30280: Cleanup threads in ayncio tests (#2501)
* bpo-30280: asyncio now cleans up threads
asyncio base TestCase now uses threading_setup() and
threading_cleanup() of test.support to cleanup threads.
* asyncio: Fix TestBaseSelectorEventLoop cleanup
bpo-30280: TestBaseSelectorEventLoop of
test.test_asyncio.test_selector_events now correctly closes the event
loop: cleanup its executor to not leak threads.
Don't override the close() method of the event loop, only override
the_close_self_pipe() method.
Diffstat (limited to 'Lib/asyncio')
-rw-r--r-- | Lib/asyncio/test_utils.py | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/Lib/asyncio/test_utils.py b/Lib/asyncio/test_utils.py index d273b08..1505950 100644 --- a/Lib/asyncio/test_utils.py +++ b/Lib/asyncio/test_utils.py @@ -32,6 +32,7 @@ from . import selectors from . import tasks from .coroutines import coroutine from .log import logger +from test import support if sys.platform == 'win32': # pragma: no cover @@ -454,6 +455,7 @@ class TestCase(unittest.TestCase): def setUp(self): self._get_running_loop = events._get_running_loop events._get_running_loop = lambda: None + self._thread_cleanup = support.threading_setup() def tearDown(self): self.unpatch_get_running_loop() @@ -464,6 +466,10 @@ class TestCase(unittest.TestCase): # in an except block of a generator self.assertEqual(sys.exc_info(), (None, None, None)) + self.doCleanups() + support.threading_cleanup(*self._thread_cleanup) + support.reap_children() + @contextlib.contextmanager def disable_logger(): |