zengbin93 / blog

17 stars 10 forks source link

笔记 - Python - 常见问题处理方法 #34

Open zengbin93 opened 6 years ago

zengbin93 commented 6 years ago

写代码碰上BUG是再正常不过,以报错信息为依据,把一些常见的BUG处理方法记录在这里。

zengbin93 commented 6 years ago

RuntimeError: There is no current event loop in thread 'Thread-1'.

原因:线程中没有获取到 event loop对象,解决方法如下: 在异步函数中,把: loop = asyncio.get_event_loop() 修改成: loop = asyncio.new_event_loop() asyncio.set_event_loop(loop)

https://stackoverflow.com/questions/46727787/runtimeerror-there-is-no-current-event-loop-in-thread-in-async-apscheduler