I'm running a Flask application that spends a long time doing calculation work on each request. This seems to block the server though. Any other requests to quicker pages block until that one is finished. I read "However Flask is just not designed for large applications or asynchronous servers" from here: http://flask.pocoo.org/docs/design/#thread-locals So it doesn't look hopeful. Any way to do this though? Or any other decent microframeworks out there that support this? Thanks.
On 25 March 2011 03:58, Joe Esposito <espo58@gmail.com> wrote: > I'm running a Flask application that spends a long time doing calculation > work on each request. > This seems to block the server though. Any other requests to quicker pages > block until that one is finished. > I read "However Flask is just not designed for large applications or > asynchronous servers" from > here: http://flask.pocoo.org/docs/design/#thread-locals > So it doesn't look hopeful. Any way to do this though? Or any other decent > microframeworks out there that support this? > Thanks. > Don't deploy with the development server in production. See http://flask.pocoo.org/docs/deploying/
I'm using Passenger on Dreamhost, with passenger_wsgi.py. As I understand it now, Celery will add concurrent support so that new, quick requests can be handled as sort of an interruption to the complex request processing. Threading would be nicer because it's a simple idea to map requests to different threads. But I'm sure there'd be major problems I'm just not thinking about. I just hope there's a way to achieve the desired behavior of handling multiple requests (both with fast and slow responses) without adding too much complexity. On Fri, Mar 25, 2011 at 4:09 AM, dag.odenhall@gmail.com < dag.odenhall@gmail.com> wrote: > On 25 March 2011 03:58, Joe Esposito <espo58@gmail.com> wrote: > > I'm running a Flask application that spends a long time doing calculation > > work on each request. > > This seems to block the server though. Any other requests to quicker > pages > > block until that one is finished. > > I read "However Flask is just not designed for large applications or > > asynchronous servers" from > > here: http://flask.pocoo.org/docs/design/#thread-locals > > So it doesn't look hopeful. Any way to do this though? Or any other > decent > > microframeworks out there that support this? > > Thanks. > > > > Don't deploy with the development server in production. > > See http://flask.pocoo.org/docs/deploying/ >
That just because app.run in Flask is one thread . Change to use wsgi like gevent, flup and others. Of course, using thing like Celery to make long time spend task execute in background is well, too. 2011/3/25 Joe Esposito <espo58@gmail.com> > I'm running a Flask application that spends a long time doing calculation > work on each request. > This seems to block the server though. Any other requests to quicker pages > block until that one is finished. > > I read "However Flask is just not designed for large applications or > asynchronous servers" from here: > http://flask.pocoo.org/docs/design/#thread-locals > So it doesn't look hopeful. Any way to do this though? Or any other decent > microframeworks out there that support this? > > Thanks. > >
On 2011-03-25 7:01 AM, heww0205 wrote:
> That just because app.run in Flask is one thread .
For testing purposes yuo can also do
app.run(threaded=True)
Regards,
Armin
Nice! That will allow Flask to handle multiple requests simultaneously? If so, that one is really good to know. Also, is there a production server equivalent? I doubt it, but if there really is a way to do it without attaching something like Celery, that'd be perfect. On Sat, Mar 26, 2011 at 7:11 AM, Armin Ronacher <armin.ronacher@active-4.com > wrote: > On 2011-03-25 7:01 AM, heww0205 wrote: > > That just because app.run in Flask is one thread . > For testing purposes yuo can also do > > app.run(threaded=True) > > > Regards, > Armin >
Hi, On Thu, Mar 24, 2011 at 10:58 PM, Joe Esposito <espo58@gmail.com> wrote: > I'm running a Flask application that spends a long time doing calculation > work on each request. > This seems to block the server though. Any other requests to quicker pages > block until that one is finished. > I read "However Flask is just not designed for large applications or > asynchronous servers" from > here: http://flask.pocoo.org/docs/design/#thread-locals > So it doesn't look hopeful. Any way to do this though? Or any other decent > microframeworks out there that support this? Celery might have what you want. http://celeryproject.org/ http://librelist.com/browser//flask/2010/9/9/ann-flask-celery-request-for-comments/ http://flask.pocoo.org/extensions/ -Ron