本文整理汇总了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)
示例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()
示例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)
示例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,)
示例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)