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


Python ResQ._current_time方法代码示例

本文整理汇总了Python中pyres.ResQ._current_time方法的典型用法代码示例。如果您正苦于以下问题:Python ResQ._current_time方法的具体用法?Python ResQ._current_time怎么用?Python ResQ._current_time使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pyres.ResQ的用法示例。


在下文中一共展示了ResQ._current_time方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: retry

# 需要导入模块: from pyres import ResQ [as 别名]
# 或者: from pyres.ResQ import _current_time [as 别名]
    def retry(self, payload_class, args):
        """This method provides a way to retry a job after a failure.
        If the jobclass defined by the payload containes a ``retry_every``
        attribute then pyres will attempt to retry the job until successful
        or until timeout defined by ``retry_timeout`` on the payload class.

        :param payload_class: the :class:`Job`-like class that needs
                              to be retried
        :type payload_class: :class:`Job`-like

        :param args: The args to be passed to the `payload_class.perform`
                     method when it is retried.
        :type args: list
        """
        retry_every = getattr(payload_class, 'retry_every', None)
        retry_timeout = getattr(payload_class, 'retry_timeout', 0)

        if retry_every:
            now = ResQ._current_time()
            first_attempt = self._payload.get("first_attempt", now)
            retry_until = first_attempt + timedelta(seconds=retry_timeout)
            retry_at = now + timedelta(seconds=retry_every)
            if retry_at < retry_until:
                self.resq.enqueue_at(retry_at, payload_class, *args,
                        **{'first_attempt':first_attempt})
                return True
        return False
开发者ID:TylerLubeck,项目名称:pyres,代码行数:29,代码来源:job.py

示例2: retry

# 需要导入模块: from pyres import ResQ [as 别名]
# 或者: from pyres.ResQ import _current_time [as 别名]
    def retry(self, payload_class, args):
        retry_every = getattr(payload_class, 'retry_every', None)
        retry_timeout = getattr(payload_class, 'retry_timeout', 0)

        if retry_every:
            now = ResQ._current_time()
            first_attempt = self._payload.get("first_attempt", now)
            retry_until = first_attempt + timedelta(seconds=retry_timeout)
            retry_at = now + timedelta(seconds=retry_every)
            if retry_at < retry_until:
                self.resq.enqueue_at(retry_at, payload_class, *args,
                        **{'first_attempt':first_attempt})
                return True
        return False
开发者ID:harikrishnan83,项目名称:pyres,代码行数:16,代码来源:job.py

示例3: retry

# 需要导入模块: from pyres import ResQ [as 别名]
# 或者: from pyres.ResQ import _current_time [as 别名]
    def retry(self, payload_class, args):
        """This method provides a way to retry a job after a failure.
        If the jobclass defined by the payload containes a ``retry_every`` attribute then pyres
        will attempt to retry the job until successful or until timeout defined by ``retry_timeout`` on the payload class.

        """
        retry_every = getattr(payload_class, "retry_every", None)
        retry_timeout = getattr(payload_class, "retry_timeout", 0)

        if retry_every:
            now = ResQ._current_time()
            first_attempt = self._payload.get("first_attempt", now)
            retry_until = first_attempt + timedelta(seconds=retry_timeout)
            retry_at = now + timedelta(seconds=retry_every)
            if retry_at < retry_until:
                self.resq.enqueue_at(retry_at, payload_class, *args, **{"first_attempt": first_attempt})
                return True
        return False
开发者ID:kvamsi,项目名称:pyres,代码行数:20,代码来源:job.py

示例4: perform

# 需要导入模块: from pyres import ResQ [as 别名]
# 或者: from pyres.ResQ import _current_time [as 别名]
 def perform(fail_until):
     if ResQ._current_time() < fail_until:
         raise Exception("Don't blame me!  I'm supposed to fail!")
     else:
         return True
开发者ID:PAStheLoD,项目名称:pyres,代码行数:7,代码来源:__init__.py


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