admin管理员组文章数量:1612097
使用异步操作:在程序里面执行threading时,会报下面的错误
There is no current event loop in thread ‘Thread-6’
这个说明在 thread-6的线程中没有事件循环,asyncio 中,先要创建一个 get_event_loop 的对象,然后需要生成一个类型是 list 的 tasks
最后把 tasks 放入 run 中进行循环处理。
将下面一句:
loop = asyncio.get_event_loop()
替换成下面两句即可
loop = asyncio.new_event_loop()
asyncio.set_event_loop(loop)
本文标签: 错误CurrentPythonasyniothread
版权声明:本文标题:【python asynio错误】There is no current event loop in thread ‘Thread-6‘ 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://www.elefans.com/dianzi/1728628309a1166781.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论