本文整理匯總了Python中aiorq.Queue.all方法的典型用法代碼示例。如果您正苦於以下問題:Python Queue.all方法的具體用法?Python Queue.all怎麽用?Python Queue.all使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類aiorq.Queue
的用法示例。
在下文中一共展示了Queue.all方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_all_queues
# 需要導入模塊: from aiorq import Queue [as 別名]
# 或者: from aiorq.Queue import all [as 別名]
def test_all_queues():
"""All queues"""
q1 = Queue('first-queue')
q2 = Queue('second-queue')
q3 = Queue('third-queue')
# Ensure a queue is added only once a job is enqueued
assert not len((yield from Queue.all()))
yield from q1.enqueue(say_hello)
assert len((yield from Queue.all())) == 1
# Ensure this holds true for multiple queues
yield from q2.enqueue(say_hello)
yield from q3.enqueue(say_hello)
names = [q.name for q in (yield from Queue.all())]
assert len((yield from Queue.all())) == 3
# Verify names
assert 'first-queue' in names
assert 'second-queue' in names
assert 'third-queue' in names
# Now empty two queues
with SynchronousConnection():
w = SynchronousWorker([SynchronousQueue('second-queue'),
SynchronousQueue('third-queue')])
w.work(burst=True)
# Queue.all() should still report the empty queues
assert len((yield from Queue.all())) == 3