mirror of https://github.com/django/django.git
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.
This commit is contained in:
parent
62b2e8b37e
commit
623c8cd8f4
|
@ -16,11 +16,10 @@ def async_unsafe(message):
|
||||||
if not os.environ.get('DJANGO_ALLOW_ASYNC_UNSAFE'):
|
if not os.environ.get('DJANGO_ALLOW_ASYNC_UNSAFE'):
|
||||||
# Detect a running event loop in this thread.
|
# Detect a running event loop in this thread.
|
||||||
try:
|
try:
|
||||||
event_loop = asyncio.get_event_loop()
|
asyncio.get_running_loop()
|
||||||
except RuntimeError:
|
except RuntimeError:
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
if event_loop.is_running():
|
|
||||||
raise SynchronousOnlyOperation(message)
|
raise SynchronousOnlyOperation(message)
|
||||||
# Pass onwards.
|
# Pass onwards.
|
||||||
return func(*args, **kwargs)
|
return func(*args, **kwargs)
|
||||||
|
|
Loading…
Reference in New Issue