summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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