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


Python Worker.process方法代码示例

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


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

示例1: test_job_failure

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

示例2: test_enqueue_from_string

# 需要导入模块: from pyres.worker import Worker [as 别名]
# 或者: from pyres.worker.Worker import process [as 别名]
 def test_enqueue_from_string(self):
     self.resq.enqueue_from_string('tests.Basic','basic','test1')
     name = "%s:%s:%s" % (os.uname()[1],os.getpid(),'basic')
     assert self.redis.llen("resque:queue:basic") == 1
     job = Job.reserve('basic', self.resq)
     worker = Worker(['basic'])
     worker.process(job)
     assert not self.redis.get('resque:worker:%s' % worker)
     assert not self.redis.get("resque:stat:failed")
     assert not self.redis.get("resque:stat:failed:%s" % name)
开发者ID:fakechris,项目名称:pyres,代码行数:12,代码来源:test_resq.py

示例3: test_enqueue_from_string

# 需要导入模块: from pyres.worker import Worker [as 别名]
# 或者: from pyres.worker.Worker import process [as 别名]
 def test_enqueue_from_string(self):
     self.resq.enqueue_from_string("tests.Basic", "basic", "test1")
     name = "%s:%s:%s" % (os.uname()[1], os.getpid(), "basic")
     assert self.redis.llen("resque:queue:basic") == 1
     job = Job.reserve("basic", self.resq)
     worker = Worker(["basic"])
     worker.process(job)
     assert not self.redis.get("resque:worker:%s" % worker)
     assert not self.redis.get("resque:stat:failed")
     assert not self.redis.get("resque:stat:failed:%s" % name)
开发者ID:aezell,项目名称:pyres,代码行数:12,代码来源:test_resq.py

示例4: test_process

# 需要导入模块: from pyres.worker import Worker [as 别名]
# 或者: from pyres.worker.Worker import process [as 别名]
 def test_process(self):
     name = "%s:%s:%s" % (os.uname()[1],os.getpid(),'basic')
     self.resq.enqueue(Basic,"test1")
     job = Job.reserve('basic', self.resq)
     worker = Worker(['basic'])
     worker.process(job)
     assert not self.redis.get('resque:worker:%s' % worker)
     assert not self.redis.get("resque:stat:failed")
     assert not self.redis.get("resque:stat:failed:%s" % name)
     self.resq.enqueue(Basic,"test1")
     worker.process()
     assert not self.redis.get('resque:worker:%s' % worker)
     assert not self.redis.get("resque:stat:failed")
     assert not self.redis.get("resque:stat:failed:%s" % name)
开发者ID:duxiaoyao,项目名称:pyres,代码行数:16,代码来源:test_worker.py

示例5: test_retries_give_up_eventually

# 需要导入模块: from pyres.worker import Worker [as 别名]
# 或者: from pyres.worker.Worker import process [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

示例6: test_retry_on_exception

# 需要导入模块: from pyres.worker import Worker [as 别名]
# 或者: from pyres.worker.Worker import process [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.process方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。