Flask,Python-增加Heroku应用上的超时时间

tmt*_*mes 5 python timeout heroku flask

我正在使用Flask构建一个Web应用程序并将其托管在Heroku上。我的应用程序会抓取网络-因此可能要花费几秒钟到20分钟的时间,具体取决于搜索条件。当我尝试运行更大的请求时,应用程序在默认的30秒后超时。有谁知道如何增加超时时间?我尝试从中更改配置文件:

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

对此:

web: gunicorn myapp:app --timeout 1200

但无处可去。

但是当我将其更改为

web: gunicorn myapp:app --timeout 5

它在5秒后超时

小智 4

30 secHeroku对任何请求的完成都有限制。如果请求花费的时间超过了,30s就会导致H12 error.

所以,在你的情况下你不能设置

网络:gunicorn myapp:app --超时 1200

参考:https: //devcenter.heroku.com/articles/python-gunicorn#worker-timeoutshttps://devcenter.heroku.com/articles/limits#http-timeouts