<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!--Converted with LaTeX2HTML 98.2 beta6 (August 14th, 1998)
original version by:  Nikos Drakos, CBLU, University of Leeds
* revised and updated by:  Marcus Hennecke, Ross Moore, Herb Swan
* with significant contributions from:
  Jens Lippmann, Marek Rouchal, Martin Wilck and others -->
<HTML>
<HEAD>
<TITLE>7.6.1 Queue Objects</TITLE>
<META NAME="description" CONTENT="7.6.1 Queue Objects">
<META NAME="keywords" CONTENT="lib">
<META NAME="resource-type" CONTENT="document">
<META NAME="distribution" CONTENT="global">
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<LINK REL="STYLESHEET" HREF="lib.css">
<LINK REL="previous" HREF="module-Queue.html">
<LINK REL="up" HREF="module-Queue.html">
<LINK REL="next" HREF="module-anydbm.html">
</HEAD>
<BODY bgcolor="#ffffff">
<div class=navigation>
<table align=center width="100%" cellpadding=0 cellspacing=2>
<tr>
<td><A HREF="module-anydbm.html"><img width=32 height=32 align=bottom border=0 alt="next"
 src="../icons/next.gif"></A></td>
<td><A HREF="module-Queue.html"><img width=32 height=32 align=bottom border=0 alt="up"
 src="../icons/up.gif"></A></td>
<td><A HREF="module-Queue.html"><img width=32 height=32 align=bottom border=0 alt="previous"
 src="../icons/previous.gif"></A></td>
<td align=center bgcolor="#99CCFF" width="100%">
 <b class=title>Python Library Reference</b></td>
<td><A HREF="contents.html"><img width=32 height=32 align=bottom border=0 alt="contents"
 src="../icons/contents.gif"></A></td>
<td><a
 href="modindex.html"><img width=32 height=32 align=bottom border=0 alt="modules"
 src="../icons/modules.gif"></a></td>
<td><A HREF="genindex.html"><img width=32 height=32 align=bottom border=0 alt="index"
 src="../icons/index.gif"></A></td>
</tr></table><b class=navlabel>Next:</b> <span class=sectref><A HREF="module-anydbm.html">7.7 anydbm  </A></span>
<b class=navlabel>Up:</b> <span class=sectref><A HREF="module-Queue.html">7.6 Queue  </A></span>
<b class=navlabel>Previous:</b> <span class=sectref><A HREF="module-Queue.html">7.6 Queue  </A></span>
<br><hr></div>
<!--End of Navigation Panel-->

<H2><A NAME="SECTION009610000000000000000"></A>
<BR>
7.6.1 Queue Objects
</H2>

<P>
Class <tt class=class>Queue</tt> 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:

<P>
<dl><dt><b><a name="l2h-1379"><tt class=method>qsize</tt></a></b> ()
<dd>
Return the approximate size of the queue.  Because of multithreading
semantics, this number is not reliable.
</dl>

<P>
<dl><dt><b><a name="l2h-1380"><tt class=method>empty</tt></a></b> ()
<dd>
Return <tt>1</tt> if the queue is empty, <tt>0</tt> otherwise.  Because
of multithreading semantics, this is not reliable.
</dl>

<P>
<dl><dt><b><a name="l2h-1381"><tt class=method>full</tt></a></b> ()
<dd>
Return <tt>1</tt> if the queue is full, <tt>0</tt> otherwise.  Because of
multithreading semantics, this is not reliable.
</dl>

<P>
<dl><dt><b><a name="l2h-1382"><tt class=method>put</tt></a></b> (<var>item</var><big>[</big><var>, block</var><big>]</big>)
<dd>
Put <var>item</var> into the queue.  If optional argument <var>block</var> is 1
(the default), block if necessary until a free slot is available.
Otherwise (<var>block</var> is 0), put <var>item</var> on the queue if a free
slot is immediately available, else raise the <tt class=exception>Full</tt>
exception.
</dl>

<P>
<dl><dt><b><a name="l2h-1383"><tt class=method>put_nowait</tt></a></b> (<var>item</var>)
<dd>
Equivalent to <tt>put(<var>item</var>, 0)</tt>.
</dl>

<P>
<dl><dt><b><a name="l2h-1384"><tt class=method>get</tt></a></b> (<big>[</big><var>block</var><big>]</big>)
<dd>
Remove and return an item from the queue.  If optional argument
<var>block</var> is 1 (the default), block if necessary until an item is
available.  Otherwise (<var>block</var> is 0), return an item if one is
immediately available, else raise the
<tt class=exception>Empty</tt> exception.
</dl>

<P>
<dl><dt><b><a name="l2h-1385"><tt class=method>get_nowait</tt></a></b> ()
<dd>
Equivalent to <tt>get(0)</tt>.
</dl><p>
<div class=navigation><hr><table align=center width="100%" cellpadding=0 cellspacing=2>
<tr>
<td><A HREF="module-anydbm.html"><img width=32 height=32 align=bottom border=0 alt="next"
 src="../icons/next.gif"></A></td>
<td><A HREF="module-Queue.html"><img width=32 height=32 align=bottom border=0 alt="up"
 src="../icons/up.gif"></A></td>
<td><A HREF="module-Queue.html"><img width=32 height=32 align=bottom border=0 alt="previous"
 src="../icons/previous.gif"></A></td>
<td align=center bgcolor="#99CCFF" width="100%">
 <b class=title>Python Library Reference</b></td>
<td><A HREF="contents.html"><img width=32 height=32 align=bottom border=0 alt="contents"
 src="../icons/contents.gif"></A></td>
<td><a
 href="modindex.html"><img width=32 height=32 align=bottom border=0 alt="modules"
 src="../icons/modules.gif"></a></td>
<td><A HREF="genindex.html"><img width=32 height=32 align=bottom border=0 alt="index"
 src="../icons/index.gif"></A></td>
</tr></table><b class=navlabel>Next:</b> <span class=sectref><A HREF="module-anydbm.html">7.7 anydbm  </A></span>
<b class=navlabel>Up:</b> <span class=sectref><A HREF="module-Queue.html">7.6 Queue  </A></span>
<b class=navlabel>Previous:</b> <span class=sectref><A HREF="module-Queue.html">7.6 Queue  </A></span>
</div>
<!--End of Navigation Panel-->
<ADDRESS>
<hr>Send comments on this document to <a href="mailto:python-docs@python.org">python-docs@python.org</a>.
</ADDRESS>
</BODY>
</HTML>
