tornado.httpclient.HTTPError:HTTP 599:请求期间超时

时间:2018-06-21 14:29:17

标签: python asynchronous tornado http-error

我正在尝试使用Python Tornado AsyncHTTPClient发出长时间异步的HTTP请求:

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))

1 个答案:

答案 0 :(得分:1)

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

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