gh-127949: deprecate asyncio.set_event_loop (#128218)

Deprecate `asyncio.set_event_loop` to be removed in Python 3.16.
This commit is contained in:
Kumar Aditya 2024-12-24 19:24:28 +05:30 committed by GitHub
parent 3ddd70ceaa
commit 9fce906825
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
16 changed files with 77 additions and 55 deletions

View file

@ -5,16 +5,22 @@
# SPDX-FileCopyrightText: Copyright (c) 2015-2021 MagicStack Inc. http://magic.io
__all__ = (
'_AbstractEventLoopPolicy',
'AbstractEventLoop', 'AbstractServer',
'Handle', 'TimerHandle',
'_get_event_loop_policy',
'get_event_loop_policy',
'_set_event_loop_policy',
'set_event_loop_policy',
'get_event_loop', 'set_event_loop', 'new_event_loop',
'_set_running_loop', 'get_running_loop',
'_get_running_loop',
"_AbstractEventLoopPolicy",
"AbstractEventLoop",
"AbstractServer",
"Handle",
"TimerHandle",
"_get_event_loop_policy",
"get_event_loop_policy",
"_set_event_loop_policy",
"set_event_loop_policy",
"get_event_loop",
"_set_event_loop",
"set_event_loop",
"new_event_loop",
"_set_running_loop",
"get_running_loop",
"_get_running_loop",
)
import contextvars
@ -801,9 +807,13 @@ def get_event_loop():
return _get_event_loop_policy().get_event_loop()
def _set_event_loop(loop):
_get_event_loop_policy().set_event_loop(loop)
def set_event_loop(loop):
"""Equivalent to calling get_event_loop_policy().set_event_loop(loop)."""
_get_event_loop_policy().set_event_loop(loop)
warnings._deprecated('asyncio.set_event_loop', remove=(3,16))
_set_event_loop(loop)
def new_event_loop():