https://github.com/python/cpython/commit/322f14eeff9e3b5853eaac3233f7580ca0214cf8
commit: 322f14eeff9e3b5853eaac3233f7580ca0214cf8
branch: main
author: Eric Snow <[email protected]>
committer: ericsnowcurrently <[email protected]>
date: 2024-10-18T16:05:12-06:00
summary:

gh-124694: In test_interpreter_pool, Restore the Asyncio Event Loop Policy 
During Cleanup (gh-125708)

This resolves a failure on the android buildbot.

files:
M Lib/test/test_concurrent_futures/test_interpreter_pool.py

diff --git a/Lib/test/test_concurrent_futures/test_interpreter_pool.py 
b/Lib/test/test_concurrent_futures/test_interpreter_pool.py
index 0de03c0d669399..5264b1bb6e9c75 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 @@ def test_idle_thread_reuse(self):
 
 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()

_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-checkins.python.org/
Member address: [email protected]

Reply via email to