Flask blueprints with gevent working outside of application context Flask blueprints with gevent working outside of application context flask flask

Flask blueprints with gevent working outside of application context


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.