gh-127949: deprecate asyncio.set_event_loop_policy (#128024)

First step towards deprecating the asyncio policy system.
This deprecates `asyncio.set_event_loop_policy` and will be removed in Python 3.16.
This commit is contained in:
Kumar Aditya 2024-12-18 11:35:29 +05:30 committed by GitHub
parent 559b0e7013
commit 5892853fb7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
46 changed files with 81 additions and 67 deletions

View file

@ -19,7 +19,7 @@ from test.test_asyncio import utils as test_utils
def tearDownModule():
asyncio.set_event_loop_policy(None)
asyncio._set_event_loop_policy(None)
class UpperProto(asyncio.Protocol):
@ -334,11 +334,11 @@ class WinPolicyTests(WindowsEventsTestCase):
old_policy = asyncio.get_event_loop_policy()
try:
asyncio.set_event_loop_policy(
asyncio._set_event_loop_policy(
asyncio.WindowsSelectorEventLoopPolicy())
asyncio.run(main())
finally:
asyncio.set_event_loop_policy(old_policy)
asyncio._set_event_loop_policy(old_policy)
def test_proactor_win_policy(self):
async def main():
@ -348,11 +348,11 @@ class WinPolicyTests(WindowsEventsTestCase):
old_policy = asyncio.get_event_loop_policy()
try:
asyncio.set_event_loop_policy(
asyncio._set_event_loop_policy(
asyncio.WindowsProactorEventLoopPolicy())
asyncio.run(main())
finally:
asyncio.set_event_loop_policy(old_policy)
asyncio._set_event_loop_policy(old_policy)
if __name__ == '__main__':