Lines Matching full:queue
1 :mod:`queue` --- A synchronized queue class
4 .. module:: queue
5 :synopsis: A synchronized queue class.
7 **Source code:** :source:`Lib/queue.py`
11 The :mod:`queue` module implements multi-producer, multi-consumer queues.
13 exchanged safely between multiple threads. The :class:`Queue` class in this
16 The module implements three types of queue, which differ only in the order in
18 queue, the first tasks added are the first retrieved. In a
19 :abbr:`LIFO (last-in, first-out)` queue, the most recently added entry is
20 the first retrieved (operating like a stack). With a priority queue,
29 :abbr:`FIFO (first-in, first-out)` queue type, :class:`SimpleQueue`, whose
33 The :mod:`queue` module defines the following classes and exceptions:
35 .. class:: Queue(maxsize=0)
37 Constructor for a :abbr:`FIFO (first-in, first-out)` queue. *maxsize* is
39 limit on the number of items that can be placed in the queue. Insertion will
40 block once this size has been reached, until queue items are consumed. If
41 *maxsize* is less than or equal to zero, the queue size is infinite.
45 Constructor for a :abbr:`LIFO (last-in, first-out)` queue. *maxsize* is
47 limit on the number of items that can be placed in the queue. Insertion will
48 block once this size has been reached, until queue items are consumed. If
49 *maxsize* is less than or equal to zero, the queue size is infinite.
54 Constructor for a priority queue. *maxsize* is an integer that sets the upperbound
55 limit on the number of items that can be placed in the queue. Insertion will
56 block once this size has been reached, until queue items are consumed. If
57 *maxsize* is less than or equal to zero, the queue size is infinite.
76 Constructor for an unbounded :abbr:`FIFO (first-in, first-out)` queue.
84 Exception raised when non-blocking :meth:`~Queue.get` (or
85 :meth:`~Queue.get_nowait`) is called
86 on a :class:`Queue` object which is empty.
91 Exception raised when non-blocking :meth:`~Queue.put` (or
92 :meth:`~Queue.put_nowait`) is called
93 on a :class:`Queue` object which is full.
98 Queue Objects
101 Queue objects (:class:`Queue`, :class:`LifoQueue`, or :class:`PriorityQueue`)
105 .. method:: Queue.qsize()
107 Return the approximate size of the queue. Note, qsize() > 0 doesn't
112 .. method:: Queue.empty()
114 Return ``True`` if the queue is empty, ``False`` otherwise. If empty()
120 .. method:: Queue.full()
122 Return ``True`` if the queue is full, ``False`` otherwise. If full()
128 .. method:: Queue.put(item, block=True, timeout=None)
130 Put *item* into the queue. If optional args *block* is true and *timeout* is
134 Otherwise (*block* is false), put an item on the queue if a free slot is
139 .. method:: Queue.put_nowait(item)
144 .. method:: Queue.get(block=True, timeout=None)
146 Remove and return an item from the queue. If optional args *block* is true and
159 .. method:: Queue.get_nowait()
167 .. method:: Queue.task_done()
169 Indicate that a formerly enqueued task is complete. Used by queue consumer
171 :meth:`task_done` tells the queue that the processing on the task is complete.
175 that had been :meth:`put` into the queue).
178 the queue.
181 .. method:: Queue.join()
183 Blocks until all items in the queue have been gotten and processed.
185 The count of unfinished tasks goes up whenever an item is added to the queue.
193 import threading, queue
195 q = queue.Queue()
224 Return the approximate size of the queue. Note, qsize() > 0 doesn't
230 Return ``True`` if the queue is empty, ``False`` otherwise. If empty()
237 Put *item* into the queue. The method never blocks and always succeeds
240 for compatibility with :meth:`Queue.put`.
246 state inside the queue. This makes it appropriate for use in
253 :meth:`Queue.put_nowait`.
258 Remove and return an item from the queue. If optional args *block* is true and
273 Class :class:`multiprocessing.Queue`
274 A queue class for use in a multi-processing (rather than multi-threading)