本文整理汇总了Python中limpyd_jobs.models.Job.enqueue_or_delay方法的典型用法代码示例。如果您正苦于以下问题:Python Job.enqueue_or_delay方法的具体用法?Python Job.enqueue_or_delay怎么用?Python Job.enqueue_or_delay使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类limpyd_jobs.models.Job
的用法示例。
在下文中一共展示了Job.enqueue_or_delay方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_enqueue_or_delay_should_delay_if_in_the_future
# 需要导入模块: from limpyd_jobs.models import Job [as 别名]
# 或者: from limpyd_jobs.models.Job import enqueue_or_delay [as 别名]
def test_enqueue_or_delay_should_delay_if_in_the_future(self):
queue = Queue.get_queue(name='test', priority=1)
job = Job(identifier='job:1')
delayed_until = datetime.utcnow() + timedelta(seconds=5)
job.enqueue_or_delay('test', 1, delayed_until=delayed_until)
self.assertEqual(queue.delayed.zcard(), 1)
self.assertEqual(queue.waiting.llen(), 0)
self.assertEqual(job.delayed_until.hget(), str(delayed_until))
self.assertEqual(job.status.hget(), STATUSES.DELAYED)
self.assertEqual(job.priority.hget(), '1')
示例2: test_enqueue_or_delay_should_enqueue_if_not_in_the_future
# 需要导入模块: from limpyd_jobs.models import Job [as 别名]
# 或者: from limpyd_jobs.models.Job import enqueue_or_delay [as 别名]
def test_enqueue_or_delay_should_enqueue_if_not_in_the_future(self):
queue = Queue.get_queue(name='test', priority=1)
job = Job(identifier='job:1')
job.enqueue_or_delay('test', 1)
self.assertEqual(queue.delayed.zcard(), 0)
self.assertEqual(queue.waiting.llen(), 1)
self.assertEqual(job.delayed_until.hget(), None)
self.assertEqual(job.status.hget(), STATUSES.WAITING)
self.assertEqual(job.priority.hget(), '1')
job2 = Job(identifier='job:2')
delayed_until = datetime.utcnow() - timedelta(seconds=5) # the past !
job2.enqueue_or_delay('test', 1, delayed_until=delayed_until)
self.assertEqual(queue.delayed.zcard(), 0)
self.assertEqual(queue.waiting.llen(), 2)
self.assertEqual(job2.delayed_until.hget(), None)
self.assertEqual(job2.status.hget(), STATUSES.WAITING)
self.assertEqual(job2.priority.hget(), '1')