summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMariusz Felisiak <felisiak.mariusz@gmail.com>2021-05-04 11:29:23 +0200
committerGitHub <noreply@github.com>2021-05-04 11:29:23 +0200
commit623c8cd8f41a99f22d39b264f7eaf7244417000b (patch)
tree201f8e8e6784d09ce7dba7cad1a6b9821c666673
parent62b2e8b37e37a313c63be40e3223ca4e830ebde3 (diff)
Refs #32074 -- Used asyncio.get_running_loop() instead of get_event_loop().
Using asyncio.get_event_loop() when there is no running event loop was deprecated in Python 3.10, see https://bugs.python.org/issue39529.
-rw-r--r--django/utils/asyncio.py5
1 files changed, 2 insertions, 3 deletions
diff --git a/django/utils/asyncio.py b/django/utils/asyncio.py
index 2405e3413e..285adbef8a 100644
--- a/django/utils/asyncio.py
+++ b/django/utils/asyncio.py
@@ -16,12 +16,11 @@ def async_unsafe(message):
if not os.environ.get('DJANGO_ALLOW_ASYNC_UNSAFE'):
# Detect a running event loop in this thread.
try:
- event_loop = asyncio.get_event_loop()
+ asyncio.get_running_loop()
except RuntimeError:
pass
else:
- if event_loop.is_running():
- raise SynchronousOnlyOperation(message)
+ raise SynchronousOnlyOperation(message)
# Pass onwards.
return func(*args, **kwargs)
return inner