• Home
  • Raw
  • Download

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)
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
44 Number of items allowed in the queue.
48 Return ``True`` if the queue is empty, ``False`` otherwise.
52 Return ``True`` if there are :attr:`maxsize` items in the queue.
54 If the queue was initialized with ``maxsize=0`` (the default),
59 Remove and return an item from the queue. If queue is empty,
69 Block until all items in the queue have been received and processed.
72 to the queue. The count goes down whenever a consumer coroutine calls
79 Put an item into the queue. If the queue is full, wait until a
84 Put an item into the queue without blocking.
90 Return the number of items in the queue.
96 Used by queue consumers. For each :meth:`~Queue.get` used to
98 queue that the processing on the task is complete.
102 call was received for every item that had been :meth:`~Queue.put`
103 into the queue).
106 items placed in the queue.
116 Priority Queue
121 A variant of :class:`Queue`; retrieves entries in priority order
128 LIFO Queue
133 A variant of :class:`Queue` that retrieves most recently added
142 This exception is raised when the :meth:`~Queue.get_nowait` method
143 is called on an empty queue.
148 Exception raised when the :meth:`~Queue.put_nowait` method is called
149 on a queue that has reached its *maxsize*.
165 async def worker(name, queue):
167 # Get a "work item" out of the queue.
168 sleep_for = await queue.get()
173 # Notify the queue that the "work item" has been processed.
174 queue.task_done()
180 # Create a queue that we will use to store our "workload".
181 queue = asyncio.Queue()
183 # Generate random timings and put them into the queue.
188 queue.put_nowait(sleep_for)
190 # Create three worker tasks to process the queue concurrently.
193 task = asyncio.create_task(worker(f'worker-{i}', queue))
196 # Wait until the queue is fully processed.
198 await queue.join()