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

假如想象 提交于 2021-01-22 09:22:13

问题


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


回答1:


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



来源:https://stackoverflow.com/questions/27233134/flask-python-increase-timeout-length-on-heroku-app

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!