I use gunicorn 19.9.0 + flask to test app:
app.py
:
from flask import Flask
import time
app = Flask(__name__)
@app.route('/')
def index():
print("in")
for i in range(10):
time.sleep(1)
print("out")
return 'hello world'
if __name__ == '__main__':
app.debug = True
app.run()
and boot cmd:
gunicorn -k eventlet -w 1 app:app --log-level=debug
test cmd:
curl localhost:8000
I think app can process multi requests at one time, but the test result is that app can only process 1 request at one time, and block in time.sleep()
!
Is that gunicorn 19.9.0 can not work as async mode?
I attempted to use gunicorn 20.0.0, and there is no problem with async mode, but another problem occurs, --> https://github.com/benoitc/gunicorn/issues/1559.
Now i have no idea which to use, gunicorn 19.9.0 or 20.0.0 ? (in our project, we use eventlet)
eventlet is not monkey-patched in gunicorn 19.8 and 19.9; that's issue https://github.com/benoitc/gunicorn/issues/1847 and was also pointed out in this thread. gunicorn 20 has an issue with sendfile
using both gevent and eventlet that affects some people serving static content; that's been fixed in master.
Depending on your situation, there are a number of options. You could try using a different worker, for example gevent. Or you could try using a different gunicorn version, even potentially master. You could also try doing the monkey-patching yourself as described in #1559.
Glad to know the static file thing has been fixed. This drove me crazy trying to figure out what was causing this. Well now I know why we should specify our versions in Pipfile/requirements.txt. When will this fix be pushed to PyPI?
Milestone for 20.0.1 here: https://github.com/benoitc/gunicorn/milestone/18
@tilgovi @jamadden i has this feature been merged in 19.x also?
20.0.2 is released.
Also merged into 19.x as 253bfa1 and is in the 19.10 release.
Most helpful comment
eventlet is not monkey-patched in gunicorn 19.8 and 19.9; that's issue https://github.com/benoitc/gunicorn/issues/1847 and was also pointed out in this thread. gunicorn 20 has an issue with
sendfile
using both gevent and eventlet that affects some people serving static content; that's been fixed in master.Depending on your situation, there are a number of options. You could try using a different worker, for example gevent. Or you could try using a different gunicorn version, even potentially master. You could also try doing the monkey-patching yourself as described in #1559.