Reputation: 20844
I wrote something like this (with more code, the important part is the sleep(5)
):
def get(self):
import time
time.sleep(5)
return jsonify({'result':'OK'})
I start my server like this:
gunicorn serve:app -b 127.0.0.2:8000 -w 4
While the app is "sleeping" is that blocking a whole worker? How does this affect gunicorn
's ability to respond?
Upvotes: 8
Views: 4169
Reputation: 14200
gunicorn
will default to using synchronous workers, which will only serve one request at a time, so yes will consume that worker for the lifetime of the long poll. gunicorn
does support asynchronous workers, which will allow a worker to serve other requests along side the long poll - see choosing a worker type:
gunicorn -k gevent -b 127.0.0.1:8000 serve:app
Upvotes: 9