本文整理汇总了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
示例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
示例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
示例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
示例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
示例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()
示例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
示例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
示例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