本文整理汇总了Python中eventlet.Timeout.cancel方法的典型用法代码示例。如果您正苦于以下问题:Python Timeout.cancel方法的具体用法?Python Timeout.cancel怎么用?Python Timeout.cancel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类eventlet.Timeout
的用法示例。
在下文中一共展示了Timeout.cancel方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: read_with_timeout
# 需要导入模块: from eventlet import Timeout [as 别名]
# 或者: from eventlet.Timeout import cancel [as 别名]
def read_with_timeout(self, size):
timeout = Timeout(self.timeout)
try:
chunk = os.read(self.obj_data, size)
except Timeout as t:
if t is timeout:
self.close()
raise t
except Exception as e:
self.close()
raise e
finally:
timeout.cancel()
return chunk
示例2: _call
# 需要导入模块: from eventlet import Timeout [as 别名]
# 或者: from eventlet.Timeout import cancel [as 别名]
def _call(self, method_name, timeout_sec, **kwargs):
LOG.debug("Calling %s" % method_name)
timeout = Timeout(timeout_sec)
try:
result = rpc.call(self.context, self._get_routing_key(),
{'method': method_name, 'args': kwargs})
LOG.debug("Result is %s" % result)
return result
except Exception as e:
LOG.error(e)
raise exception.GuestError(original_message=str(e))
except Timeout as t:
if t is not timeout:
raise
else:
raise exception.GuestTimeout()
finally:
timeout.cancel()
示例3: poll_response
# 需要导入模块: from eventlet import Timeout [as 别名]
# 或者: from eventlet.Timeout import cancel [as 别名]
def poll_response(self, response):
"""
The API might return a job nr in the response in case of a async
response: https://github.com/fog/fog/issues/575
"""
status = response.status
timeout = Timeout(CONF[CFG_GROUP].job_timeout)
try:
while status == 307:
time.sleep(1)
url = response.headers.get('Location')
LOG.debug("Polling %s" % url)
polled_response = self.get(url)
status = response.status
except Timeout as t:
if t == timeout:
raise DynTimeoutError('Timeout reached when pulling job.')
finally:
timeout.cancel()
return polled_response