當前位置: 首頁>>代碼示例>>Python>>正文


Python Queue.dequeue_any方法代碼示例

本文整理匯總了Python中aiorq.Queue.dequeue_any方法的典型用法代碼示例。如果您正苦於以下問題:Python Queue.dequeue_any方法的具體用法?Python Queue.dequeue_any怎麽用?Python Queue.dequeue_any使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在aiorq.Queue的用法示例。


在下文中一共展示了Queue.dequeue_any方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_dequeue_any

# 需要導入模塊: from aiorq import Queue [as 別名]
# 或者: from aiorq.Queue import dequeue_any [as 別名]
def test_dequeue_any():
    """Fetching work from any given queue."""

    fooq = Queue('foo')
    barq = Queue('bar')

    assert not (yield from Queue.dequeue_any([fooq, barq], None))

    # Enqueue a single item
    yield from barq.enqueue(say_hello)
    job, queue = yield from Queue.dequeue_any([fooq, barq], None)
    assert job.func == say_hello
    assert queue == barq

    # Enqueue items on both queues
    yield from barq.enqueue(say_hello, 'for Bar')
    yield from fooq.enqueue(say_hello, 'for Foo')

    job, queue = yield from Queue.dequeue_any([fooq, barq], None)
    assert queue == fooq
    assert job.func == say_hello
    assert job.origin == fooq.name
    assert job.args[0] == 'for Foo', 'Foo should be dequeued first.'

    job, queue = yield from Queue.dequeue_any([fooq, barq], None)
    assert queue == barq
    assert job.func == say_hello
    assert job.origin == barq.name
    assert job.args[0] == 'for Bar', 'Bar should be dequeued second.'
開發者ID:essobi,項目名稱:aiorq,代碼行數:31,代碼來源:test_queue.py

示例2: test_dequeue_any_ignores_nonexisting_jobs

# 需要導入模塊: from aiorq import Queue [as 別名]
# 或者: from aiorq.Queue import dequeue_any [as 別名]
def test_dequeue_any_ignores_nonexisting_jobs():
    """Dequeuing (from any queue) silently ignores non-existing jobs."""

    q = Queue('low')
    uuid = '49f205ab-8ea3-47dd-a1b5-bfa186870fc8'
    yield from q.push_job_id(uuid)

    # Dequeue simply ignores the missing job and returns None
    assert (yield from q.count) == 1
    assert not (yield from Queue.dequeue_any([Queue(), Queue('low')], None))
    assert not (yield from q.count)
開發者ID:essobi,項目名稱:aiorq,代碼行數:13,代碼來源:test_queue.py


注:本文中的aiorq.Queue.dequeue_any方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。