gh-127949: deprecate asyncio policy classes (#128216)

This commit is contained in:
Kumar Aditya 2024-12-24 17:30:26 +05:30 committed by GitHub
parent 3f6a618e49
commit a391d80f4b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 82 additions and 34 deletions

View file

@ -328,14 +328,15 @@ class WinPolicyTests(WindowsEventsTestCase):
def test_selector_win_policy(self):
async def main():
self.assertIsInstance(
asyncio.get_running_loop(),
asyncio.SelectorEventLoop)
self.assertIsInstance(asyncio.get_running_loop(), asyncio.SelectorEventLoop)
old_policy = asyncio._get_event_loop_policy()
try:
asyncio._set_event_loop_policy(
asyncio.WindowsSelectorEventLoopPolicy())
with self.assertWarnsRegex(
DeprecationWarning,
"'asyncio.WindowsSelectorEventLoopPolicy' is deprecated",
):
asyncio._set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())
asyncio.run(main())
finally:
asyncio._set_event_loop_policy(old_policy)
@ -348,8 +349,11 @@ class WinPolicyTests(WindowsEventsTestCase):
old_policy = asyncio._get_event_loop_policy()
try:
asyncio._set_event_loop_policy(
asyncio.WindowsProactorEventLoopPolicy())
with self.assertWarnsRegex(
DeprecationWarning,
"'asyncio.WindowsProactorEventLoopPolicy' is deprecated",
):
asyncio._set_event_loop_policy(asyncio.WindowsProactorEventLoopPolicy())
asyncio.run(main())
finally:
asyncio._set_event_loop_policy(old_policy)