我正在尝试在 Tornado 中使用 AsyncHTTPClient 对通过 http 可用的“设备”进行多次标注:
def ext_call(self, params):
device = AsyncHTTPClient()
request = HTTPRequest(...)
return partial(device.fetch, request)
@coroutine
def _do_call(self, someid):
acall = self.ext_call(params)
waitkey = str(someid)
acall(callback = (yield Callback(waitkey)))
response = yield Wait(waitkey)
raise Return(response)
def get_device_data(self, lst):
for someid in lst:
r = self._do_call(someid)
print 'response', r
但不是 HTTP 响应,因为 AsyncHTTPClient 应该在 .fetch 之后返回,我得到了这个:
response <tornado.concurrent.TracebackFuture object at 0x951840c>
为什么这不像http://www.tornadoweb.org/en/stable/gen.html中的示例那样工作 ?