Answer the question
In order to leave comments, you need to log in
How to set response timeout in gunicorn?
Guys, need help!) Deployed Django app on Heroku. Everything works except for one. My application performs the function of parsing a group conversation on Vkontakte: it downloads the entire history of correspondence to a file and counts the number of messages from each participant.
The analysis function itself in Dzhang takes a long time - about 45 seconds. This is superimposed by a large volume of correspondence and a limitation of requests per second of the Vkontakte API. So when I call the Janga view responsible for parsing, it only returns a response after 45-50 seconds.
(I will only get to Channels in a month, so I can’t run the function in a separate worker now - I need to grow.)
As a result, Gunicorn, if there is no response from the Janga server within 30 seconds, returns Request timeout. Here are the logs from Heroku:
2017-07-22T11:05:14.860483+00:00 heroku[router]: at=error code=H12 desc="<b>Request timeout</b>" method=GET path="/update/" host=vki141b.herokuapp.com request_id=9a53ee89-bae3-4ee0-92a5-f8265c8d5e0e fwd="94.25.180.161" dyno=web.1 connect=1ms service=30000ms status=503 bytes=0 protocol=https
2017-07-22T11:05:14.871450+00:00 app[web.1]: [2017-07-22 11:05:14 +0000] [4] [CRITICAL] WORKER TIMEOUT (pid:9)
2017-07-22T11:05:14.871946+00:00 app[web.1]: [2017-07-22 11:05:14 +0000] [9] [INFO] Worker exiting (pid: 9)
2017-07-22T11:05:14.951888+00:00 app[web.1]: [2017-07-22 11:05:14 +0000] [16] [INFO] Booting worker with pid: 16
Failed to find application: 'statistic'
[2017-07-22 14:10:25 +0300] [9138] [INFO] Worker exiting (pid: 9138)
[2017-07-22 14:10:25 +0300] [9135] [INFO] Shutting down: Master
[2017-07-22 14:10:25 +0300] [9135] [INFO] Reason: App failed to load.
Answer the question
In order to leave comments, you need to log in
docs.gunicorn.org/en/stable/run.html#django
In your project, next to settings.py, there should be a wsgi.py file with something like this:
import os
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "project.settings")
from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question