当前位置: 首页>>代码示例>>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;未经允许,请勿转载。