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


Python job.Job类代码示例

本文整理汇总了Python中pyres.job.Job的典型用法代码示例。如果您正苦于以下问题:Python Job类的具体用法?Python Job怎么用?Python Job使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: test_requeue

 def test_requeue(self):
     self.resq.enqueue(Basic,"test1")
     job = Job.reserve('basic',self.resq)
     e = Exception('problem')
     fail_object = job.fail(e)
     assert self.resq.size('basic') == 0
     failure.requeue(self.resq, fail_object)
     assert self.resq.size('basic') == 1
     job = Job.reserve('basic',self.resq)
     assert job._queue == 'basic'
     assert job._payload == {'class':'tests.Basic','args':['test1']}
开发者ID:aezell,项目名称:pyres,代码行数:11,代码来源:test_failure.py

示例2: test_requeue

 def test_requeue(self):
     self.resq.enqueue(self.job_class, "test1")
     job = Job.reserve(self.queue_name, self.resq)
     e = Exception("problem")
     fail_object = job.fail(e)
     assert self.resq.size(self.queue_name) == 0
     failure.requeue(self.resq, fail_object)
     assert self.resq.size(self.queue_name) == 1
     job = Job.reserve(self.queue_name, self.resq)
     assert job._queue == self.queue_name
     mod_with_class = "{module}.{klass}".format(module=self.job_class.__module__, klass=self.job_class.__name__)
     assert job._payload == {"class": mod_with_class, "args": ["test1"]}
开发者ID:ruthenium,项目名称:pyres,代码行数:12,代码来源:test_failure.py

示例3: test_requeue

 def test_requeue(self):
     self.resq.enqueue(self.job_class,"test1")
     job = Job.reserve(self.queue_name,self.resq)
     e = Exception('problem')
     fail_object = job.fail(e)
     assert self.resq.size(self.queue_name) == 0
     failure.requeue(self.resq, fail_object)
     assert self.resq.size(self.queue_name) == 1
     job = Job.reserve(self.queue_name,self.resq)
     assert job._queue == self.queue_name
     mod_with_class = '{module}.{klass}'.format(
         module=self.job_class.__module__,
         klass=self.job_class.__name__)
     self.assertEqual(job._payload, {'class':mod_with_class,'args':['test1'],'enqueue_timestamp': job.enqueue_timestamp})
开发者ID:Affectiva,项目名称:pyres,代码行数:14,代码来源:test_failure.py

示例4: reserve

 def reserve(self):
     for q in self.queues:
         print "Checking %s" % q
         job = Job.reserve(q, self.resq)
         if job:
             print "Found job on %s" % q
             return job
开发者ID:deepu,项目名称:pyres,代码行数:7,代码来源:worker.py

示例5: test_working_on

 def test_working_on(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.working_on(job)
     assert self.redis.exists("resque:worker:%s" % name)
开发者ID:duxiaoyao,项目名称:pyres,代码行数:7,代码来源:test_worker.py

示例6: reserve

 def reserve(self):
     for q in self.queues:
         logging.debug('checking queue %s' % q)
         job = Job.reserve(q, self.resq, self.__str__())
         if job:
             logging.info('Found job on %s' % q)
             return job
开发者ID:mjrusso,项目名称:pyres,代码行数:7,代码来源:worker.py

示例7: reserve

 def reserve(self):
     for q in self.queues:
         #print "Checking %s" % q
         job = Job.reserve(q, self.resq, self.__str__())
         if job:
             if self.verbose:
                 print "Found job on %s" % q
             return job
开发者ID:fakechris,项目名称:pyres,代码行数:8,代码来源:worker.py

示例8: test_clear

 def test_clear(self):
     self.resq.enqueue(Basic,"test1")
     job = Job.reserve('basic',self.resq)
     e = Exception('problem')
     job.fail(e)
     assert self.redis.llen('resque:failed') == 1
     failure.clear(self.resq)
     assert self.redis.llen('resque:failed') == 0
开发者ID:aezell,项目名称:pyres,代码行数:8,代码来源:test_failure.py

示例9: test_clear

 def test_clear(self):
     self.resq.enqueue(self.job_class,"test1")
     job = Job.reserve(self.queue_name,self.resq)
     e = Exception('problem')
     job.fail(e)
     assert self.redis.llen('resque:failed') == 1
     failure.clear(self.resq)
     assert self.redis.llen('resque:failed') == 0
开发者ID:Affectiva,项目名称:pyres,代码行数:8,代码来源:test_failure.py

示例10: test_create

 def test_create(self):
     self.resq.enqueue(Basic,"test1")
     job = Job.reserve('basic',self.resq)
     e = Exception('test')
     fail = failure.create(e, 'basic', job._payload)
     assert isinstance(fail._payload, dict)
     fail.save()
     assert failure.count(self.resq) == 1
     assert self.redis.llen('resque:failed') == 1
开发者ID:aezell,项目名称:pyres,代码行数:9,代码来源:test_failure.py

示例11: test_create

 def test_create(self):
     self.resq.enqueue(self.job_class, "test1")
     job = Job.reserve(self.queue_name, self.resq)
     e = Exception("test")
     fail = failure.create(e, self.queue_name, job._payload)
     assert isinstance(fail._payload, dict)
     fail.save(self.resq)
     assert failure.count(self.resq) == 1
     assert self.redis.llen("resque:failed") == 1
开发者ID:ruthenium,项目名称:pyres,代码行数:9,代码来源:test_failure.py

示例12: test_enqueue_from_string

 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,代码行数:10,代码来源:test_resq.py

示例13: test_enqueue_from_string

 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,代码行数:10,代码来源:test_resq.py

示例14: test_state

 def test_state(self):
     worker = Worker(['basic'])
     assert worker.state() == 'idle'
     self.resq.enqueue_from_string('tests.Basic','basic','test1')
     worker.register_worker()
     job = Job.reserve('basic', self.resq)
     worker.working_on(job)
     assert worker.state() == 'working'
     worker.done_working()
     assert worker.state() == 'idle'
开发者ID:duxiaoyao,项目名称:pyres,代码行数:10,代码来源:test_worker.py

示例15: test_get_job

 def test_get_job(self):
     worker = Worker(['basic'])
     self.resq.enqueue(Basic,"test1")
     job = Job.reserve('basic', self.resq)
     worker.working_on(job)
     name = "%s:%s:%s" % (os.uname()[1],os.getpid(),'basic')
     assert worker.job() == ResQ.decode(self.redis.get('resque:worker:%s' % name))
     worker.done_working()
     w2 = Worker(['basic'])
     print w2.job()
     assert w2.job() == {}
开发者ID:fakechris,项目名称:pyres,代码行数:11,代码来源:test_worker.py


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