mirror of
https://github.com/python/cpython.git
synced 2025-07-24 11:44:31 +00:00
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.
This commit is contained in:
parent
21a0a6c9f8
commit
b903067462
2 changed files with 9 additions and 5 deletions
|
@ -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():
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue