def poll(self, action, body):
if not action.NEED_POLL:
return raise_error(202, body)
location = body['location']
with async_timeout.timeout(self._polling_timeout):
count = 0
while True:
status, body = await self._do_request('GET', location)
if status in [200, 503]:
return {"value": json.loads(body)}
count += 1
await asyncio.sleep(self._polling_interval)
# polling timeout
return raise_error(500, "Location {} polling timeout, count: {}".format(location, count))
评论列表
文章目录