【问题标题】:Flask, Python - Increase timeout length on Heroku app [duplicate]Flask,Python - 增加 Heroku 应用程序的超时长度 [重复]
【发布时间】:2015-01-29 17:43:11
【问题描述】:

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

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

到这里:

web: gunicorn myapp:app --timeout 1200

但一无所获。

但是当我把它改成

web: gunicorn myapp:app --timeout 5

它在 5 秒时超时

【问题讨论】:

    标签: python heroku flask timeout


    【解决方案1】:

    Heroku 对完成任何请求的限制为 30 sec。如果请求超过30s,那么它会导致H12 error

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

    web: gunicorn myapp:app --timeout 1200

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

    【讨论】:

      猜你喜欢
      • 2015-06-09
      • 2016-02-20
      • 2023-03-09
      • 1970-01-01
      • 2021-02-16
      • 1970-01-01
      • 2022-01-05
      • 1970-01-01
      • 2014-09-09
      相关资源
      最近更新 更多