本文整理汇总了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, [])
示例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')