diff options
| -rw-r--r-- | Lib/unittest/async_case.py | 2 | ||||
| -rw-r--r-- | Misc/NEWS.d/next/Library/2022-04-19-04-33-39.gh-issue-91676.ceQBwh.rst | 4 |
2 files changed, 6 insertions, 0 deletions
diff --git a/Lib/unittest/async_case.py b/Lib/unittest/async_case.py index 2323119..d9c694e 100644 --- a/Lib/unittest/async_case.py +++ b/Lib/unittest/async_case.py @@ -148,6 +148,8 @@ class IsolatedAsyncioTestCase(TestCase): # shutdown asyncgens loop.run_until_complete(loop.shutdown_asyncgens()) finally: + # Prevent our executor environment from leaking to future tests. + loop.run_until_complete(loop.shutdown_default_executor()) asyncio.set_event_loop(None) loop.close() diff --git a/Misc/NEWS.d/next/Library/2022-04-19-04-33-39.gh-issue-91676.ceQBwh.rst b/Misc/NEWS.d/next/Library/2022-04-19-04-33-39.gh-issue-91676.ceQBwh.rst new file mode 100644 index 0000000..dfbaef4 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2022-04-19-04-33-39.gh-issue-91676.ceQBwh.rst @@ -0,0 +1,4 @@ +Fix :class:`unittest.IsolatedAsyncioTestCase` to shutdown the per test event +loop executor before returning from its ``run`` method so that a not yet +stopped or garbage collected executor state does not persist beyond the +test. |
