I have an flask app that closely follows fast.ai's render app: https://github.com/render-examples/fastai-v3. It uses asyncio to download the model while the page renders. The following code sets it up:
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()
I noticed that when FLASK_DEBUG=1, the first line throws the error:
RuntimeError: There is no current event loop in thread 'Thread-1'.
But when FLASK_DEBUG=0, it doesn't. But the app is harder to debug. Has anyone come across this issue and what's causing it?