7.6.1 Queue Objects

Class Queue implements queue objects and has the methods described below. This class can be derived from in order to implement other queue organizations (e.g. stack) but the inheritable interface is not described here. See the source code for details. The public methods are:

qsize ()
Return the approximate size of the queue. Because of multithreading semantics, this number is not reliable.

empty ()
Return 1 if the queue is empty, 0 otherwise. Because of multithreading semantics, this is not reliable.

full ()
Return 1 if the queue is full, 0 otherwise. Because of multithreading semantics, this is not reliable.

put (item[, block])
Put item into the queue. If optional argument block is 1 (the default), block if necessary until a free slot is available. Otherwise (block is 0), put item on the queue if a free slot is immediately available, else raise the Full exception.

put_nowait (item)
Equivalent to put(item, 0).

get ([block])
Remove and return an item from the queue. If optional argument block is 1 (the default), block if necessary until an item is available. Otherwise (block is 0), return an item if one is immediately available, else raise the Empty exception.

get_nowait ()
Equivalent to get(0).


Send comments on this document to python-docs@python.org.