gh-130322: drop deprecation of asyncio.set_event_loop (#132349)

This commit is contained in:
Kumar Aditya 2025-04-12 12:03:52 +05:30 committed by GitHub
parent e6ef47ac22
commit 05d27a84f4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
16 changed files with 46 additions and 64 deletions

View file

@ -212,8 +212,8 @@ class BaseTaskTests:
self.assertEqual(t.result(), 'ok')
# Deprecated in 3.10, undeprecated in 3.12
asyncio._set_event_loop(self.loop)
self.addCleanup(asyncio._set_event_loop, None)
asyncio.set_event_loop(self.loop)
self.addCleanup(asyncio.set_event_loop, None)
t = asyncio.ensure_future(notmuch())
self.assertIs(t._loop, self.loop)
self.loop.run_until_complete(t)
@ -2202,8 +2202,8 @@ class BaseTaskTests:
async def coro():
return 42
asyncio._set_event_loop(self.loop)
self.addCleanup(asyncio._set_event_loop, None)
asyncio.set_event_loop(self.loop)
self.addCleanup(asyncio.set_event_loop, None)
outer = asyncio.shield(coro())
self.assertEqual(outer._loop, self.loop)
res = self.loop.run_until_complete(outer)
@ -3322,8 +3322,8 @@ class FutureGatherTests(GatherTestsBase, test_utils.TestCase):
def test_constructor_empty_sequence_use_global_loop(self):
# Deprecated in 3.10, undeprecated in 3.12
asyncio._set_event_loop(self.one_loop)
self.addCleanup(asyncio._set_event_loop, None)
asyncio.set_event_loop(self.one_loop)
self.addCleanup(asyncio.set_event_loop, None)
fut = asyncio.gather()
self.assertIsInstance(fut, asyncio.Future)
self.assertIs(fut._loop, self.one_loop)
@ -3430,8 +3430,8 @@ class CoroutineGatherTests(GatherTestsBase, test_utils.TestCase):
# Deprecated in 3.10, undeprecated in 3.12
async def coro():
return 'abc'
asyncio._set_event_loop(self.other_loop)
self.addCleanup(asyncio._set_event_loop, None)
asyncio.set_event_loop(self.other_loop)
self.addCleanup(asyncio.set_event_loop, None)
gen1 = coro()
gen2 = coro()
fut = asyncio.gather(gen1, gen2)