如何解决运行时错误:线程“Dummy-2”中没有当前事件循环 - 使用 mod_wsgi 运行 Django API
我在 Ubuntu-20.4 ec2 实例中有一个与 mod_wsgi (python3.8) 连接的 Django API。当我使用 Ec2 实例的公共 DNS 运行它时,我收到此错误。如何解决这个问题
错误:
There is no current event loop in thread 'Dummy-2'.
Django Version: 3.1.4
Exception Type: RuntimeError
Exception Value:
There is no current event loop in thread 'Dummy-2'.
Exception Location: /usr/lib/python3.8/asyncio/events.py,line 642,in get_event_loop
Python Executable: /home/ubuntu/django_project/env/bin/python3
Python Version: 3.8.5
Python Path:
['/home/ubuntu/django_project','/usr/lib/python38.zip','/usr/lib/python3.8','/usr/lib/python3.8/lib-dynload','/home/ubuntu/django_project/env/lib/python3.8/site-packages']
Server time: Sun,20 Dec 2020 14:40:28 +0000
事件.py
def get_event_loop(self):
"""Get the event loop for the current context.
Returns an instance of EventLoop or raises an exception.
"""
if (self._local._loop is None and not self._local._set_called and
isinstance(threading.current_thread(),threading._MainThread)):
self.set_event_loop(self.new_event_loop())
if self._local._loop is None:
raise RuntimeError('There is no current event loop in thread %r.' %
threading.current_thread().name)
return self._local._loop
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。