python - 30 秒超时后,从 Heroku 流式传输大文件失败

标签 python http heroku timeout web.py

我有一个 python web worker,它根据客户请求流式传输一个大文件。 30 秒后连接被 Heroku 终止。我正在使用 web.py 并产生新的输出。根据 Heroku 文档:

Cedar supports HTTP 1.1 features such as long-polling and streaming responses. An application has an initial 30 second window to respond with a single byte back to the client. However, each byte transmitted thereafter (either received from the client or sent by your application) resets a rolling 55 second window. If no data is sent during the 55 second window, the connection will be terminated.

我每 55 秒发送超过 1 个字节,但连接仍然终止。

这些是我正在使用的 header

web.header('Content-type' , 'application/zip')
web.header('Content-Disposition', 'attachment; filename="images.zip"')

我什至尝试添加:

web.header('Transfer-Encoding','chunked')

我做错了什么吗?

最佳答案

问题似乎是错误的 gunicorn 设置造成的。在 Procfile 中延长 gunicron 超时就达到了目的:

--timeout 300

关于python - 30 秒超时后,从 Heroku 流式传输大文件失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17609342/

相关文章:

python - 使用 boto3 进行 Cloudformation 通配符搜索

ruby-on-rails - 为什么 ?format=csv 文件没有扩展名

python - 如何读取传输编码 : chunks? 中 block 的大小

python - 在python中将多列表转换为字典

python - 更新最新 PySide 后 Pyinstaller 错误

python - 根据 if-elif-else 条件创建新列

PHP - 检查最终 URL 是否存在

ruby-on-rails - 成功的 heroku 运行 rake db :migrate but columns don't seem to work

ruby-on-rails - Heroku - 从 Sqlite 迁移到 Postgres 时遇到问题

heroku - 如何清除 Heroku 日志