Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flask, Python - Increase timeout length on Heroku app [duplicate]

I'm building a web app using Flask and hosting it on Heroku. My app scrapes the web—so it can take anywhere from a few seconds to 20 minutes, depending on the search criteria. When I try to run bigger requests, the application times out after the default 30 seconds. Does anyone know how to increase the timeout length? I've tried changing the Profile from this:

web: gunicorn myapp:app --log-file=-

to this:

web: gunicorn myapp:app --timeout 1200

but got nowhere.

But when I changed it to

web: gunicorn myapp:app --timeout 5

it timed out at 5 seconds

like image 893
tmthyjames Avatar asked Dec 01 '14 16:12

tmthyjames


1 Answers

Heroku has a limit of 30 sec for any request to complete. If the request takes more than 30s then it leads to H12 error.

So, in your case you can't set

web: gunicorn myapp:app --timeout 1200

Ref: https://devcenter.heroku.com/articles/python-gunicorn#worker-timeouts and https://devcenter.heroku.com/articles/limits#http-timeouts

like image 82
Girish Avatar answered Sep 27 '22 00:09

Girish