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