| 1 | <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> |
| 2 | <html> |
| 3 | <head> |
| 4 | <link rel="STYLESHEET" href="lib.css" type='text/css' /> |
| 5 | <link rel="SHORTCUT ICON" href="../icons/pyfav.png" type="image/png" /> |
| 6 | <link rel='start' href='../index.html' title='Python Documentation Index' /> |
| 7 | <link rel="first" href="lib.html" title='Python Library Reference' /> |
| 8 | <link rel='contents' href='contents.html' title="Contents" /> |
| 9 | <link rel='index' href='genindex.html' title='Index' /> |
| 10 | <link rel='last' href='about.html' title='About this document...' /> |
| 11 | <link rel='help' href='about.html' title='About this document...' /> |
| 12 | <link rel="next" href="module-mmap.html" /> |
| 13 | <link rel="prev" href="module-dummythreading.html" /> |
| 14 | <link rel="parent" href="someos.html" /> |
| 15 | <link rel="next" href="QueueObjects.html" /> |
| 16 | <meta name='aesop' content='information' /> |
| 17 | <title>7.8 Queue -- A synchronized queue class</title> |
| 18 | </head> |
| 19 | <body> |
| 20 | <DIV CLASS="navigation"> |
| 21 | <div id='top-navigation-panel' xml:id='top-navigation-panel'> |
| 22 | <table align="center" width="100%" cellpadding="0" cellspacing="2"> |
| 23 | <tr> |
| 24 | <td class='online-navigation'><a rel="prev" title="7.7 dummy_threading " |
| 25 | href="module-dummythreading.html"><img src='../icons/previous.png' |
| 26 | border='0' height='32' alt='Previous Page' width='32' /></A></td> |
| 27 | <td class='online-navigation'><a rel="parent" title="7. Optional Operating System" |
| 28 | href="someos.html"><img src='../icons/up.png' |
| 29 | border='0' height='32' alt='Up One Level' width='32' /></A></td> |
| 30 | <td class='online-navigation'><a rel="next" title="7.8.1 Queue Objects" |
| 31 | href="QueueObjects.html"><img src='../icons/next.png' |
| 32 | border='0' height='32' alt='Next Page' width='32' /></A></td> |
| 33 | <td align="center" width="100%">Python Library Reference</td> |
| 34 | <td class='online-navigation'><a rel="contents" title="Table of Contents" |
| 35 | href="contents.html"><img src='../icons/contents.png' |
| 36 | border='0' height='32' alt='Contents' width='32' /></A></td> |
| 37 | <td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png' |
| 38 | border='0' height='32' alt='Module Index' width='32' /></a></td> |
| 39 | <td class='online-navigation'><a rel="index" title="Index" |
| 40 | href="genindex.html"><img src='../icons/index.png' |
| 41 | border='0' height='32' alt='Index' width='32' /></A></td> |
| 42 | </tr></table> |
| 43 | <div class='online-navigation'> |
| 44 | <b class="navlabel">Previous:</b> |
| 45 | <a class="sectref" rel="prev" href="module-dummythreading.html">7.7 dummy_threading </A> |
| 46 | <b class="navlabel">Up:</b> |
| 47 | <a class="sectref" rel="parent" href="someos.html">7. Optional Operating System</A> |
| 48 | <b class="navlabel">Next:</b> |
| 49 | <a class="sectref" rel="next" href="QueueObjects.html">7.8.1 Queue Objects</A> |
| 50 | </div> |
| 51 | <hr /></div> |
| 52 | </DIV> |
| 53 | <!--End of Navigation Panel--> |
| 54 | |
| 55 | <H1><A NAME="SECTION009800000000000000000"> |
| 56 | 7.8 <tt class="module">Queue</tt> -- |
| 57 | A synchronized queue class</A> |
| 58 | </H1> |
| 59 | |
| 60 | <P> |
| 61 | <A NAME="module-Queue"></A> |
| 62 | |
| 63 | <P> |
| 64 | The <tt class="module">Queue</tt> module implements a multi-producer, multi-consumer |
| 65 | FIFO queue. It is especially useful in threads programming when |
| 66 | information must be exchanged safely between multiple threads. The |
| 67 | <tt class="class">Queue</tt> class in this module implements all the required locking |
| 68 | semantics. It depends on the availability of thread support in |
| 69 | Python. |
| 70 | |
| 71 | <P> |
| 72 | The <tt class="module">Queue</tt> module defines the following class and exception: |
| 73 | |
| 74 | <P> |
| 75 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> |
| 76 | <td><nobr><b><span class="typelabel">class</span> <tt id='l2h-2752' xml:id='l2h-2752' class="class">Queue</tt></b>(</nobr></td> |
| 77 | <td><var>maxsize</var>)</td></tr></table></dt> |
| 78 | <dd> |
| 79 | Constructor for the class. <var>maxsize</var> is an integer that sets the |
| 80 | upperbound limit on the number of items that can be placed in the |
| 81 | queue. Insertion will block once this size has been reached, until |
| 82 | queue items are consumed. If <var>maxsize</var> is less than or equal to |
| 83 | zero, the queue size is infinite. |
| 84 | </dl> |
| 85 | |
| 86 | <P> |
| 87 | <dl><dt><b><span class="typelabel">exception</span> <tt id='l2h-2753' xml:id='l2h-2753' class="exception">Empty</tt></b></dt> |
| 88 | <dd> |
| 89 | Exception raised when non-blocking <tt class="method">get()</tt> (or |
| 90 | <tt class="method">get_nowait()</tt>) is called on a <tt class="class">Queue</tt> object which is |
| 91 | empty. |
| 92 | </dd></dl> |
| 93 | |
| 94 | <P> |
| 95 | <dl><dt><b><span class="typelabel">exception</span> <tt id='l2h-2754' xml:id='l2h-2754' class="exception">Full</tt></b></dt> |
| 96 | <dd> |
| 97 | Exception raised when non-blocking <tt class="method">put()</tt> (or |
| 98 | <tt class="method">put_nowait()</tt>) is called on a <tt class="class">Queue</tt> object which is |
| 99 | full. |
| 100 | </dd></dl> |
| 101 | |
| 102 | <P> |
| 103 | |
| 104 | <p><br /></p><hr class='online-navigation' /> |
| 105 | <div class='online-navigation'> |
| 106 | <!--Table of Child-Links--> |
| 107 | <A NAME="CHILD_LINKS"><STRONG>Subsections</STRONG></a> |
| 108 | |
| 109 | <UL CLASS="ChildLinks"> |
| 110 | <LI><A href="QueueObjects.html">7.8.1 Queue Objects</a> |
| 111 | </ul> |
| 112 | <!--End of Table of Child-Links--> |
| 113 | </div> |
| 114 | |
| 115 | <DIV CLASS="navigation"> |
| 116 | <div class='online-navigation'> |
| 117 | <p></p><hr /> |
| 118 | <table align="center" width="100%" cellpadding="0" cellspacing="2"> |
| 119 | <tr> |
| 120 | <td class='online-navigation'><a rel="prev" title="7.7 dummy_threading " |
| 121 | href="module-dummythreading.html"><img src='../icons/previous.png' |
| 122 | border='0' height='32' alt='Previous Page' width='32' /></A></td> |
| 123 | <td class='online-navigation'><a rel="parent" title="7. Optional Operating System" |
| 124 | href="someos.html"><img src='../icons/up.png' |
| 125 | border='0' height='32' alt='Up One Level' width='32' /></A></td> |
| 126 | <td class='online-navigation'><a rel="next" title="7.8.1 Queue Objects" |
| 127 | href="QueueObjects.html"><img src='../icons/next.png' |
| 128 | border='0' height='32' alt='Next Page' width='32' /></A></td> |
| 129 | <td align="center" width="100%">Python Library Reference</td> |
| 130 | <td class='online-navigation'><a rel="contents" title="Table of Contents" |
| 131 | href="contents.html"><img src='../icons/contents.png' |
| 132 | border='0' height='32' alt='Contents' width='32' /></A></td> |
| 133 | <td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png' |
| 134 | border='0' height='32' alt='Module Index' width='32' /></a></td> |
| 135 | <td class='online-navigation'><a rel="index" title="Index" |
| 136 | href="genindex.html"><img src='../icons/index.png' |
| 137 | border='0' height='32' alt='Index' width='32' /></A></td> |
| 138 | </tr></table> |
| 139 | <div class='online-navigation'> |
| 140 | <b class="navlabel">Previous:</b> |
| 141 | <a class="sectref" rel="prev" href="module-dummythreading.html">7.7 dummy_threading </A> |
| 142 | <b class="navlabel">Up:</b> |
| 143 | <a class="sectref" rel="parent" href="someos.html">7. Optional Operating System</A> |
| 144 | <b class="navlabel">Next:</b> |
| 145 | <a class="sectref" rel="next" href="QueueObjects.html">7.8.1 Queue Objects</A> |
| 146 | </div> |
| 147 | </div> |
| 148 | <hr /> |
| 149 | <span class="release-info">Release 2.4.2, documentation updated on 28 September 2005.</span> |
| 150 | </DIV> |
| 151 | <!--End of Navigation Panel--> |
| 152 | <ADDRESS> |
| 153 | See <i><a href="about.html">About this document...</a></i> for information on suggesting changes. |
| 154 | </ADDRESS> |
| 155 | </BODY> |
| 156 | </HTML> |