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


Python Job.enqueue_or_delay方法代码示例

本文整理汇总了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')
开发者ID:limpyd,项目名称:redis-limpyd-jobs,代码行数:12,代码来源:models.py

示例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')
开发者ID:limpyd,项目名称:redis-limpyd-jobs,代码行数:21,代码来源:models.py


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