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


Python Worker.get_failed方法代码示例

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


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

示例1: test_kills_stale_workers_after_timeout

# 需要导入模块: from pyres.worker import Worker [as 别名]
# 或者: from pyres.worker.Worker import get_failed [as 别名]
    def test_kills_stale_workers_after_timeout(self):
        timeout = 1

        worker = Worker(['basic'], timeout=timeout)
        self.resq.enqueue(TimeoutJob, timeout + 1)

        assert worker.get_failed() == 0
        worker.fork_worker(worker.reserve())
        assert worker.get_failed() == 1
开发者ID:jbardin,项目名称:pyres,代码行数:11,代码来源:test_worker.py

示例2: test_detect_code_0_os_exit_as_success

# 需要导入模块: from pyres.worker import Worker [as 别名]
# 或者: from pyres.worker.Worker import get_failed [as 别名]
    def test_detect_code_0_os_exit_as_success(self):
        worker = Worker(['basic'])
        self.resq.enqueue(PrematureHardExitJob, 0)

        assert worker.job() == {}
        assert worker.get_failed() == 0

        worker.fork_worker(worker.reserve())

        assert worker.job() == {}
        assert worker.get_failed() == 0
开发者ID:jbardin,项目名称:pyres,代码行数:13,代码来源:test_worker.py

示例3: test_detect_non_0_sys_exit_as_failure

# 需要导入模块: from pyres.worker import Worker [as 别名]
# 或者: from pyres.worker.Worker import get_failed [as 别名]
    def test_detect_non_0_sys_exit_as_failure(self):
        worker = Worker(['basic'])
        self.resq.enqueue(PrematureExitJob, 9)

        assert worker.job() == {}
        assert worker.get_failed() == 0

        worker.fork_worker(worker.reserve())

        assert worker.job() == {}
        assert worker.get_failed() == 1
开发者ID:jbardin,项目名称:pyres,代码行数:13,代码来源:test_worker.py

示例4: test_detect_crashed_workers_as_failures

# 需要导入模块: from pyres.worker import Worker [as 别名]
# 或者: from pyres.worker.Worker import get_failed [as 别名]
    def test_detect_crashed_workers_as_failures(self):
        worker = Worker(['basic'])
        self.resq.enqueue(CrashJob)

        assert worker.job() == {}
        assert worker.get_failed() == 0

        worker.fork_worker(worker.reserve())

        assert worker.job() == {}
        assert worker.get_failed() == 1
开发者ID:jbardin,项目名称:pyres,代码行数:13,代码来源:test_worker.py

示例5: test_failed

# 需要导入模块: from pyres.worker import Worker [as 别名]
# 或者: from pyres.worker.Worker import get_failed [as 别名]
 def test_failed(self):
     name = "%s:%s:%s" % (os.uname()[1],os.getpid(),'basic')
     worker = Worker(['basic'])
     worker.failed()
     assert self.redis.exists("resque:stat:failed")
     assert self.redis.exists("resque:stat:failed:%s" % name)
     assert self.redis.get("resque:stat:failed") == str(1)
     assert self.redis.get("resque:stat:failed:%s" % name) == str(1)
     assert worker.get_failed() == 1
     worker.failed()
     assert self.redis.get("resque:stat:failed") == str(2)
     assert self.redis.get("resque:stat:failed:%s" % name) == str(2)
     assert worker.get_failed() == 2
开发者ID:duxiaoyao,项目名称:pyres,代码行数:15,代码来源:test_worker.py

示例6: test_kills_stale_workers_after_timeout

# 需要导入模块: from pyres.worker import Worker [as 别名]
# 或者: from pyres.worker.Worker import get_failed [as 别名]
    def test_kills_stale_workers_after_timeout(self):
        import signal
        timeout = 1

        worker = Worker(['basic'], timeout=timeout)
        self.resq.enqueue(TimeoutJob, timeout + 1)

        child = os.fork()
        if child:
            assert worker.get_failed() == 0
            time.sleep(timeout + 2)
            os.kill(child, signal.SIGKILL)
            os.waitpid(-1, os.WNOHANG)
            assert worker.get_failed() == 1
        else:
            worker.work()
开发者ID:ghedsouza,项目名称:pyres,代码行数:18,代码来源:test_worker.py

示例7: test_sigterm_worker_gets_requeued

# 需要导入模块: from pyres.worker import Worker [as 别名]
# 或者: from pyres.worker.Worker import get_failed [as 别名]
    def test_sigterm_worker_gets_requeued(self):
        worker = Worker(['basic'])
        self.resq.enqueue(SigtermJob, 'string argument')

        assert worker.job() == {}
        assert worker.get_failed() == 0

        job = worker.reserve()
        worker.fork_worker(job)

        # our last job should land back in the queue
        job2 = worker.reserve()
        assert str(job2) == str(job)

        # didn't run job2, so there shouldn't be more jobs
        assert worker.reserve(timeout=1) == None

        assert worker.job() == {}
        assert worker.get_failed() == 0
开发者ID:jbardin,项目名称:pyres,代码行数:21,代码来源:test_worker.py

示例8: test_retries_give_up_eventually

# 需要导入模块: from pyres.worker import Worker [as 别名]
# 或者: from pyres.worker.Worker import get_failed [as 别名]
    def test_retries_give_up_eventually(self):
        now = datetime.datetime.utcnow()
        self.set_utcnow(now)
        worker = Worker(['basic'])
        scheduler = Scheduler()

        # queue up a job that will fail for 60 seconds
        self.resq.enqueue(RetryOnExceptionJob,
                now + datetime.timedelta(seconds=60))
        worker.process()
        assert worker.get_failed() == 0

        # check it retries the first time
        self.set_utcnow(now + datetime.timedelta(seconds=5))
        scheduler.handle_delayed_items()
        assert None == worker.process()
        assert worker.get_failed() == 0

        # check it fails when we've been trying too long
        self.set_utcnow(now + datetime.timedelta(seconds=20))
        scheduler.handle_delayed_items()
        assert None == worker.process()
        assert worker.get_failed() == 1
开发者ID:duxiaoyao,项目名称:pyres,代码行数:25,代码来源:test_worker.py

示例9: test_retry_on_exception

# 需要导入模块: from pyres.worker import Worker [as 别名]
# 或者: from pyres.worker.Worker import get_failed [as 别名]
    def test_retry_on_exception(self):
        now = datetime.datetime.utcnow()
        self.set_utcnow(now)
        worker = Worker(['basic'])
        scheduler = Scheduler()

        # queue up a job that will fail for 30 seconds
        self.resq.enqueue(RetryOnExceptionJob,
                now + datetime.timedelta(seconds=30))
        worker.process()
        assert worker.get_failed() == 0

        # check it retries the first time
        self.set_utcnow(now + datetime.timedelta(seconds=5))
        scheduler.handle_delayed_items()
        assert None == worker.process()
        assert worker.get_failed() == 0

        # check it runs fine when it's stopped crashing
        self.set_utcnow(now + datetime.timedelta(seconds=60))
        scheduler.handle_delayed_items()
        assert True == worker.process()
        assert worker.get_failed() == 0
开发者ID:duxiaoyao,项目名称:pyres,代码行数:25,代码来源:test_worker.py


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