错误 RuntimeError: This event loop is already running
具体内容如下。
File "D:\anaconda3\lib\site-packages\uvicorn\main.py", line 393, in run
server.run()
File "D:\anaconda3\lib\site-packages\uvicorn\server.py", line 50, in run
loop.run_until_complete(self.serve(sockets=sockets))
File "D:\anaconda3\lib\asyncio\base_events.py", line 592, in run_until_complete
self._check_running()
File "D:\anaconda3\lib\asyncio\base_events.py", line 552, in _check_running
raise RuntimeError('This event loop is already running')
参考链接: 最后一段,讲的很细.
安装 pip3 install nest_asyncio
,并在代码开头加入以下两行代码。
import nest_asyncio
nest_asyncio.apply()