Skip to content

Commit 322f14e

Browse files
gh-124694: In test_interpreter_pool, Restore the Asyncio Event Loop Policy During Cleanup (gh-125708)
This resolves a failure on the android buildbot.
1 parent c8fd4b1 commit 322f14e

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

Lib/test/test_concurrent_futures/test_interpreter_pool.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,19 @@ def test_idle_thread_reuse(self):
282282

283283
class AsyncioTest(InterpretersMixin, testasyncio_utils.TestCase):
284284

285+
@classmethod
286+
def setUpClass(cls):
287+
# Most uses of asyncio will implicitly call set_event_loop_policy()
288+
# with the default policy if a policy hasn't been set already.
289+
# If that happens in a test, like here, we'll end up with a failure
290+
# when --fail-env-changed is used. That's why the other tests that
291+
# use asyncio are careful to set the policy back to None and why
292+
# we're careful to do so here. We also validate that no other
293+
# tests left a policy in place, just in case.
294+
policy = support.maybe_get_event_loop_policy()
295+
assert policy is None, policy
296+
cls.addClassCleanup(lambda: asyncio.set_event_loop_policy(None))
297+
285298
def setUp(self):
286299
super().setUp()
287300
self.loop = asyncio.new_event_loop()

0 commit comments

Comments
 (0)