0
我有疑問。關閉龍捲風處理程序
我有這部分代碼:
#Code for retrieving the MAC address of the node
como_url = "".join(['http://', options.como_address, ':', options.como_port,
'/ztc_config?netid=', netid,
'&opcode_group=', opcodegroupr,
'&opcode=', opcoder, '&start=-5m&end=-1s'])
print como_url
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))
else:
for line in response.body.split("\n"):
if line != "":
value = int(line.split(" ")[6])
ret['response'] = value
self.write(tornado.escape.json_encode(ret))
,我想的是,如果從服務器的響應爲空,處理程序被關閉。
我不知道這是否
if response.error:
ret['error'] = 'Error while retrieving the response'
self.write(tornado.escape.json_encode(ret))
是正確的關閉處理,並在頁面返回。或者如果我必須做self.finish .....
非常感謝。