本文整理汇总了Python中pyres.worker.Worker.fork_worker方法的典型用法代码示例。如果您正苦于以下问题:Python Worker.fork_worker方法的具体用法?Python Worker.fork_worker怎么用?Python Worker.fork_worker使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyres.worker.Worker
的用法示例。
在下文中一共展示了Worker.fork_worker方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_kills_stale_workers_after_timeout
# 需要导入模块: from pyres.worker import Worker [as 别名]
# 或者: from pyres.worker.Worker import fork_worker [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 fork_worker [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 fork_worker [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 fork_worker [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_sigterm_worker_gets_requeued
# 需要导入模块: from pyres.worker import Worker [as 别名]
# 或者: from pyres.worker.Worker import fork_worker [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