当前位置: 首页>>代码示例>>Python>>正文


Python Timeout.cancel方法代码示例

本文整理汇总了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
开发者ID:ajiang38740,项目名称:swift-storlets,代码行数:17,代码来源:storlet_handler.py

示例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()
开发者ID:hub-cap,项目名称:reddwarf_lite,代码行数:21,代码来源:api.py

示例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
开发者ID:CingHu,项目名称:designate,代码行数:24,代码来源:impl_dynect.py


注:本文中的eventlet.Timeout.cancel方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。