Flask blueprints with gevent working outside of application context

a 夏天 提交于 2019-12-05 20:18:32

For historical purposes: putting the from myproject.app import create_app inside the send_async_email instead of at the top of with the rest of the imports solved the ImportError, because it caused a circular dependency.

You need to define your async function within your view and use the @copy_current_request_context decorator, so that it can have access to the current request (and app) context.

For details: documentation of flask.copy_current_request_context.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!