龙卷风异步请求

2024-06-28 19:40:11 发布

您现在位置:Python中文网/ 问答频道 /正文

我有龙卷风的部分代码:

............
como_url = "".join(['http://', options.como_address, ':', options.como_port, 
                        '/ztc_config?netid=0&opcode_group=0&opcode=0&start=-20s&end=-1s'])

http_client = AsyncHTTPClient()
response = yield tornado.gen.Task(http_client.fetch, como_url)

ret = {}
if response.error:
    ret['error'] = 'Error while retrieving the response'
    self.write(tornado.escape.json_encode(ret))
    self.finish()
else:
.........

我向传感器发送一个命令,然后向数据库发出一个http请求,以从传感器检索响应。 在我做出反应并采取行动之后。在

现在,我必须发送两次http请求来检索响应。我第一次向传感器发送命令时,是因为请求太快而无法接收响应。在

我重新发送命令后,发现响应正确,一切正常。在

为什么?我如何设置我不知道请求的超时。。。或者我怎样才能在龙卷风中重新发送两次请求?在

谢谢。在

编辑

我是这样写的:

^{pr2}$

我得到:

HTTPResponse(code=200,request_time=0.30609703063964844,buffer=<io.BytesIO object at 0x276a1d0>,_body=None,time_info={},request=<tornado.httpclient.HTTPRequest object at 0x2764310>,effective_url='http://131.114.52.207:44444/ztc_config?netid=0&opcode_group=0&opcode=0&start=-20s&end=-1s',headers={'Content-Type': 'text/plain'},error=None)

为什么请求时间=0????在


Tags: 命令confighttpurlresponsegrouperror传感器