For things like test_asyncio.test_thread this was causing frequent
"environment modified by test" errors as the executor threads had not
always stopped running after the test was over.
(cherry picked from commit
61570ae0bc1507a62bee9d8b9bc2ff7155da7061)
Co-authored-by: Gregory P. Smith <greg@krypto.org>
# 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()
--- /dev/null
+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.