66 :synopsis: A synchronized queue class.
77
88
9- The :mod: `Queue ` module implements a multi-producer, multi-consumer FIFO queue .
9+ The :mod: `Queue ` module implements multi-producer, multi-consumer queues .
1010It is especially useful in threaded programming when information must be
1111exchanged safely between multiple threads. The :class: `Queue ` class in this
1212module implements all the required locking semantics. It depends on the
1313availability of thread support in Python; see the :mod: `threading `
1414module.
1515
16- The :mod: `Queue ` module defines the following class and exception:
16+ Implements three types of queue whose only difference is the order that
17+ the entries are retrieved. In a FIFO queue, the first tasks added are
18+ the first retrieved. In a LIFO queue, the most recently added entry is
19+ the first retrieved (operating like a stack). With a priority queue,
20+ the entries are kept sorted (using the :mod: `heapq ` module) and the
21+ lowest valued entry is retrieved first.
1722
23+ The :mod: `Queue ` module defines the following classes and exceptions:
1824
1925.. class :: Queue(maxsize)
2026
21- Constructor for the class . *maxsize * is an integer that sets the upperbound
27+ Constructor for a FIFO queue . *maxsize * is an integer that sets the upperbound
2228 limit on the number of items that can be placed in the queue. Insertion will
2329 block once this size has been reached, until queue items are consumed. If
2430 *maxsize * is less than or equal to zero, the queue size is infinite.
2531
32+ .. class :: LifoQueue(maxsize)
33+
34+ Constructor for a LIFO queue. *maxsize * is an integer that sets the upperbound
35+ limit on the number of items that can be placed in the queue. Insertion will
36+ block once this size has been reached, until queue items are consumed. If
37+ *maxsize * is less than or equal to zero, the queue size is infinite.
38+
39+ .. class :: PriorityQueue(maxsize)
40+
41+ Constructor for a priority queue. *maxsize * is an integer that sets the upperbound
42+ limit on the number of items that can be placed in the queue. Insertion will
43+ block once this size has been reached, until queue items are consumed. If
44+ *maxsize * is less than or equal to zero, the queue size is infinite.
45+
46+ The lowest valued entries are retrieved first (the lowest valued entry is the
47+ one returned by ``sorted(list(entries))[0] ``). A typical pattern for entries
48+ is a tuple in the form: ``(priority_number, data) ``.
2649
2750.. exception :: Empty
2851
@@ -41,10 +64,8 @@ The :mod:`Queue` module defines the following class and exception:
4164Queue Objects
4265-------------
4366
44- Class :class: `Queue ` implements queue objects and has the methods described
45- below. This class can be derived from in order to implement other queue
46- organizations (e.g. stack) but the inheritable interface is not described here.
47- See the source code for details. The public methods are:
67+ Queue objects (:class: ``Queue` `, :class: ``LifoQueue` `, or :class: ``PriorityQueue` `
68+ provide the public methods described below.
4869
4970
5071.. method :: Queue.qsize()
0 commit comments