Stop using asyncio.get_event_loop()

It is deprecated in newer Python versions.
Closes #4013.
This commit is contained in:
Lonami Exo
2023-01-11 21:02:29 +01:00
parent fb97a8aa87
commit 83bafa25e3
14 changed files with 82 additions and 99 deletions

View File

@@ -153,7 +153,7 @@ def retry_range(retries, force_retry=True):
while attempt != retries:
attempt += 1
yield attempt
async def _maybe_await(value):
@@ -426,7 +426,10 @@ class _FileStream(io.IOBase):
# endregion
def get_running_loop():
if sys.version_info[:2] <= (3, 6):
return asyncio._get_running_loop()
return asyncio.get_running_loop()
if sys.version_info >= (3, 7):
try:
return asyncio.get_running_loop()
except RuntimeError:
return asyncio.get_event_loop_policy().get_event_loop()
else:
return asyncio.get_event_loop()