首页 > 解决方案 > tornado.httpclient.HTTPError:HTTP 599:请求期间超时

问题描述

我正在尝试使用 Python Tornado 发出一个长的异步 http 请求AsyncHTTPClient

url = 'http://do_something_for_more_than_20_seconds.com/
client = httpclient.AsyncHTTPClient()
response = await client.fetch(url, method='GET')

但是,20 秒后,我收到此错误:

tornado.httpclient.HTTPError: HTTP 599: Timeout during request

如何配置client以允许长请求?

我试图在初始化之后添加这个配置行client,但它仍然不起作用:

client.configure(None, defaults=dict(connect_timeout=60, request_timeout=120))

标签: pythonasynchronoustornadohttp-error

解决方案


如果您在客户端的构造函数中移动超时配置,它应该可以工作

client = httpclient.AsyncHTTPClient(defaults=dict(request_timeout=180))

推荐阅读