summaryrefslogtreecommitdiffstats
path: root/Lib/asyncio/test_utils.py
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2017-06-30 15:20:31 (GMT)
committerGitHub <noreply@github.com>2017-06-30 15:20:31 (GMT)
commit0e0bc8762570277147a09278c829e4a85a331596 (patch)
tree19c4a680191eab13742796715e7fa6539d8ede92 /Lib/asyncio/test_utils.py
parent714afccf6e7644d21ce1a39e90bf83cb0c9a74f1 (diff)
downloadcpython-0e0bc8762570277147a09278c829e4a85a331596.zip
cpython-0e0bc8762570277147a09278c829e4a85a331596.tar.gz
cpython-0e0bc8762570277147a09278c829e4a85a331596.tar.bz2
bpo-30280: Cleanup threads in ayncio tests (#2501) (#2512)
* 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. (cherry picked from commit b9030674624c181d6e9047cdb14ad65bb6c84c66)
Diffstat (limited to 'Lib/asyncio/test_utils.py')
-rw-r--r--Lib/asyncio/test_utils.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/Lib/asyncio/test_utils.py b/Lib/asyncio/test_utils.py
index fe90b9c..a1686c5 100644
--- a/Lib/asyncio/test_utils.py
+++ b/Lib/asyncio/test_utils.py
@@ -33,6 +33,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
@@ -455,6 +456,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()
@@ -465,6 +467,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()
+
if not compat.PY34:
# Python 3.3 compatibility
def subTest(self, *args, **kwargs):