Skip to content

Commit

Permalink
pythongh-124694: In test_interpreter_pool, Restore the Asyncio Event …
Browse files Browse the repository at this point in the history
…Loop Policy During Cleanup (pythongh-125708)

This resolves a failure on the android buildbot.
  • Loading branch information
ericsnowcurrently authored Oct 18, 2024
1 parent c8fd4b1 commit 322f14e
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions Lib/test/test_concurrent_futures/test_interpreter_pool.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit 322f14e

Please sign in to comment.