bpo-34037: test_asyncio uses shutdown_default_executor() (GH-16284)

This commit is contained in:
Victor Stinner 2019-09-19 16:45:06 +02:00 committed by GitHub
parent b2dd2dd6e9
commit 079931d122
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 3 deletions

View file

@ -509,9 +509,11 @@ def get_function_source(func):
class TestCase(unittest.TestCase):
@staticmethod
def close_loop(loop):
executor = loop._default_executor
if executor is not None:
executor.shutdown(wait=True)
if loop._default_executor is not None:
if not loop.is_closed():
loop.run_until_complete(loop.shutdown_default_executor())
else:
loop._default_executor.shutdown(wait=True)
loop.close()
policy = support.maybe_get_event_loop_policy()
if policy is not None: