當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。