【发布时间】:2020-02-26 04:15:40
【问题描述】:
我有一个烧瓶应用程序,它紧跟 fast.ai 的渲染应用程序:https://github.com/render-examples/fastai-v3。它使用 asyncio 在页面呈现时下载模型。下面的代码设置它:
loop = asyncio.get_event_loop()
tasks = [asyncio.ensure_future(setup_learner())] #setup_learner downloads the model
learn = loop.run_until_complete(asyncio.gather(*tasks))[0]
loop.close()
我注意到当 FLASK_DEBUG=1 时,第一行抛出错误:
RuntimeError: 线程 'Thread-1' 中没有当前事件循环。
但是当 FLASK_DEBUG=0 时,它不会。但该应用程序更难调试。有没有人遇到过这个问题,是什么原因造成的?
【问题讨论】:
标签: debugging flask python-asyncio