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


Python Queue.dequeue方法代碼示例

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


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

示例1: test_dequeue_ignores_nonexisting_jobs

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

    q = Queue()
    uuid = '49f205ab-8ea3-47dd-a1b5-bfa186870fc8'
    yield from q.push_job_id(uuid)
    yield from q.push_job_id(uuid)
    result = yield from q.enqueue(say_hello, 'Nick', foo='bar')
    yield from q.push_job_id(uuid)

    # Dequeue simply ignores the missing job and returns None
    assert (yield from q.count) == 4
    assert (yield from q.dequeue()).id == result.id
    assert not (yield from q.dequeue())
    assert not (yield from q.count)
開發者ID:essobi,項目名稱:aiorq,代碼行數:17,代碼來源:test_queue.py

示例2: test_dequeue_deleted_jobs

# 需要導入模塊: from aiorq import Queue [as 別名]
# 或者: from aiorq.Queue import dequeue [as 別名]
def test_dequeue_deleted_jobs():
    """Dequeueing deleted jobs from queues don't blow the stack."""

    q = Queue()
    for _ in range(1, 1000):
        job = yield from q.enqueue(say_hello)
        yield from job.delete()
    yield from q.dequeue()
開發者ID:essobi,項目名稱:aiorq,代碼行數:10,代碼來源:test_queue.py

示例3: test_dequeue_class_method

# 需要導入模塊: from aiorq import Queue [as 別名]
# 或者: from aiorq.Queue import dequeue [as 別名]
def test_dequeue_class_method():
    """Dequeueing class method jobs from queues."""

    q = Queue()
    yield from q.enqueue(Number.divide, 3, 4)

    job = yield from q.dequeue()

    assert job.instance.__dict__ == Number.__dict__
    assert job.func.__name__ == 'divide'
    assert job.args == (3, 4)
開發者ID:essobi,項目名稱:aiorq,代碼行數:13,代碼來源:test_queue.py

示例4: test_dequeue_instance_method

# 需要導入模塊: from aiorq import Queue [as 別名]
# 或者: from aiorq.Queue import dequeue [as 別名]
def test_dequeue_instance_method():
    """Dequeueing instance method jobs from queues."""

    q = Queue()
    n = Number(2)
    yield from q.enqueue(n.div, 4)

    job = yield from q.dequeue()

    # The instance has been pickled and unpickled, so it is now a
    # separate object. Test for equality using each object's __dict__
    # instead.
    assert job.instance.__dict__ == n.__dict__
    assert job.func.__name__ == 'div'
    assert job.args == (4,)
開發者ID:essobi,項目名稱:aiorq,代碼行數:17,代碼來源:test_queue.py

示例5: test_dequeue

# 需要導入模塊: from aiorq import Queue [as 別名]
# 或者: from aiorq.Queue import dequeue [as 別名]
def test_dequeue():
    """Dequeueing jobs from queues."""

    # Set up
    q = Queue()
    result = yield from q.enqueue(say_hello, 'Rick', foo='bar')

    # Dequeue a job (not a job ID) off the queue
    assert (yield from q.count)
    job = yield from q.dequeue()
    assert job.id == result.id
    assert job.func == say_hello
    assert job.origin == q.name
    assert job.args[0] == 'Rick'
    assert job.kwargs['foo'] == 'bar'

    # ...and assert the queue count when down
    assert not (yield from q.count)
開發者ID:essobi,項目名稱:aiorq,代碼行數:20,代碼來源:test_queue.py


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