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


Python Queue.get_waiting_keys方法代码示例

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


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

示例1: test_get_waiting_keys_should_return_all_keys_for_a_name

# 需要导入模块: from limpyd_jobs.models import Queue [as 别名]
# 或者: from limpyd_jobs.models.Queue import get_waiting_keys [as 别名]
    def test_get_waiting_keys_should_return_all_keys_for_a_name(self):
        # create two with the same name and different priorities
        q0 = Queue.get_queue(name='test', priority=0)
        q1 = Queue.get_queue(name='test', priority=1)
        # and one with a different name
        qx = Queue.get_queue(name='foobar')

        # test we can get all keys for 'test', ordered by priority desc
        keys = Queue.get_waiting_keys('test')
        self.assertEqual(keys, [q1.waiting.key, q0.waiting.key])

        # tests for foobar
        keys = Queue.get_waiting_keys('foobar')
        self.assertEqual(keys, [qx.waiting.key])

        # tests for non existing name
        keys = Queue.get_waiting_keys('qux')
        self.assertEqual(keys, [])
开发者ID:limpyd,项目名称:redis-limpyd-jobs,代码行数:20,代码来源:models.py

示例2: test_adding_a_job_should_create_a_queue_with_the_job

# 需要导入模块: from limpyd_jobs.models import Queue [as 别名]
# 或者: from limpyd_jobs.models.Queue import get_waiting_keys [as 别名]
    def test_adding_a_job_should_create_a_queue_with_the_job(self):
        job = Job.add_job(identifier='job:1', queue_name='test', priority=5)

        # count queues
        keys = Queue.get_waiting_keys('test')
        self.assertEqual(len(keys), 1)

        # get the new queue, should not create it (number of keys should be 1)
        queue = Queue.get_queue(name='test', priority=5)
        keys = Queue.get_waiting_keys('test')
        self.assertEqual(len(keys), 1)

        # check that the job is in the queue
        jobs = queue.waiting.lrange(0, -1)
        self.assertEqual(jobs, [job.ident])

        # ... with the correct status and priority
        self.assert_job_status_and_priority(job, STATUSES.WAITING, '5')
开发者ID:limpyd,项目名称:redis-limpyd-jobs,代码行数:20,代码来源:models.py


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