Lines Matching full:queue
14 :mod:`queue` module. Although asyncio queues are not thread-safe,
18 use :func:`asyncio.wait_for` function to do queue operations with a
23 Queue chapter
26 .. class:: Queue(maxsize=0, \*, loop=None)
28 A first in, first out (FIFO) queue.
30 If *maxsize* is less than or equal to zero, the queue size is
32 ``await put()`` blocks when the queue reaches *maxsize*
35 Unlike the standard library threading :mod:`queue`, the size of
36 the queue is always known and can be returned by calling the
47 Number of items allowed in the queue.
51 Return ``True`` if the queue is empty, ``False`` otherwise.
55 Return ``True`` if there are :attr:`maxsize` items in the queue.
57 If the queue was initialized with ``maxsize=0`` (the default),
62 Remove and return an item from the queue. If queue is empty,
72 Block until all items in the queue have been received and processed.
75 to the queue. The count goes down whenever a consumer coroutine calls
82 Put an item into the queue. If the queue is full, wait until a
87 Put an item into the queue without blocking.
93 Return the number of items in the queue.
99 Used by queue consumers. For each :meth:`~Queue.get` used to
101 queue that the processing on the task is complete.
105 call was received for every item that had been :meth:`~Queue.put`
106 into the queue).
109 items placed in the queue.
112 Priority Queue
117 A variant of :class:`Queue`; retrieves entries in priority order
124 LIFO Queue
129 A variant of :class:`Queue` that retrieves most recently added
138 This exception is raised when the :meth:`~Queue.get_nowait` method
139 is called on an empty queue.
144 Exception raised when the :meth:`~Queue.put_nowait` method is called
145 on a queue that has reached its *maxsize*.
161 async def worker(name, queue):
163 # Get a "work item" out of the queue.
164 sleep_for = await queue.get()
169 # Notify the queue that the "work item" has been processed.
170 queue.task_done()
176 # Create a queue that we will use to store our "workload".
177 queue = asyncio.Queue()
179 # Generate random timings and put them into the queue.
184 queue.put_nowait(sleep_for)
186 # Create three worker tasks to process the queue concurrently.
189 task = asyncio.create_task(worker(f'worker-{i}', queue))
192 # Wait until the queue is fully processed.
194 await queue.join()