本文整理汇总了Python中eventlet.Timeout类的典型用法代码示例。如果您正苦于以下问题:Python Timeout类的具体用法?Python Timeout怎么用?Python Timeout使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Timeout类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: read_with_timeout
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
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
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
示例4: __str__
def __str__(self):
return '%s: %s' % (Timeout.__str__(self), self.msg)
示例5: __init__
def __init__(self, seconds=None, msg=None):
Timeout.__init__(self, seconds=seconds)
self.msg = msg