summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorEric Snow <ericsnowcurrently@gmail.com>2024-10-18 22:05:12 (GMT)
committerGitHub <noreply@github.com>2024-10-18 22:05:12 (GMT)
commit322f14eeff9e3b5853eaac3233f7580ca0214cf8 (patch)
treebaea9f6c2c22220020f9e93cd5e7470c6dc85bad /Lib
parentc8fd4b12e3db49d795de55f74d9bac445c059f1b (diff)
downloadcpython-322f14eeff9e3b5853eaac3233f7580ca0214cf8.zip
cpython-322f14eeff9e3b5853eaac3233f7580ca0214cf8.tar.gz
cpython-322f14eeff9e3b5853eaac3233f7580ca0214cf8.tar.bz2
gh-124694: In test_interpreter_pool, Restore the Asyncio Event Loop Policy During Cleanup (gh-125708)
This resolves a failure on the android buildbot.
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/test_concurrent_futures/test_interpreter_pool.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/Lib/test/test_concurrent_futures/test_interpreter_pool.py b/Lib/test/test_concurrent_futures/test_interpreter_pool.py
index 0de03c0..5264b1b 100644
--- a/Lib/test/test_concurrent_futures/test_interpreter_pool.py
+++ b/Lib/test/test_concurrent_futures/test_interpreter_pool.py
@@ -282,6 +282,19 @@ class InterpreterPoolExecutorTest(
class AsyncioTest(InterpretersMixin, testasyncio_utils.TestCase):
+ @classmethod
+ def setUpClass(cls):
+ # Most uses of asyncio will implicitly call set_event_loop_policy()
+ # with the default policy if a policy hasn't been set already.
+ # If that happens in a test, like here, we'll end up with a failure
+ # when --fail-env-changed is used. That's why the other tests that
+ # use asyncio are careful to set the policy back to None and why
+ # we're careful to do so here. We also validate that no other
+ # tests left a policy in place, just in case.
+ policy = support.maybe_get_event_loop_policy()
+ assert policy is None, policy
+ cls.addClassCleanup(lambda: asyncio.set_event_loop_policy(None))
+
def setUp(self):
super().setUp()
self.loop = asyncio.new_event_loop()