Le 22/03/2012 19:45, Craig Younkins a écrit :
I'm trying to wrap my head around how I should be using application
configuration in asynchronous tasks. The code should overlap
significantly, because a lot of the things I need during an async task
are things I need during a request.
Right now the celeryd and the web request handler have the same config
and both create a Flask application object. How do I keep track of the
current application object in the celery server? current_app is not
available because it is not in a request context. Any suggestions? I
feel like I might be approaching this the wrong way.
Hi,
There is no current app when you are not in a test request context, but
you can make a "fake" request context:
with app.test_request_context():
do_stuff()
This was added to help with testing (hence the same) but it works just
as well for an async job runner.
Regards,
--
Simon Sapin
--
You received this message because you are subscribed to the Google Groups
"pocoo-libs" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/pocoo-libs?hl=en.