Commit | Line | Data |
---|---|---|
920dae64 AT |
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="prev" href="module-Queue.html" /> | |
13 | <link rel="parent" href="module-Queue.html" /> | |
14 | <link rel="next" href="module-mmap.html" /> | |
15 | <meta name='aesop' content='information' /> | |
16 | <title>7.8.1 Queue Objects</title> | |
17 | </head> | |
18 | <body> | |
19 | <DIV CLASS="navigation"> | |
20 | <div id='top-navigation-panel' xml:id='top-navigation-panel'> | |
21 | <table align="center" width="100%" cellpadding="0" cellspacing="2"> | |
22 | <tr> | |
23 | <td class='online-navigation'><a rel="prev" title="7.8 Queue " | |
24 | href="module-Queue.html"><img src='../icons/previous.png' | |
25 | border='0' height='32' alt='Previous Page' width='32' /></A></td> | |
26 | <td class='online-navigation'><a rel="parent" title="7.8 Queue " | |
27 | href="module-Queue.html"><img src='../icons/up.png' | |
28 | border='0' height='32' alt='Up One Level' width='32' /></A></td> | |
29 | <td class='online-navigation'><a rel="next" title="7.9 mmap " | |
30 | href="module-mmap.html"><img src='../icons/next.png' | |
31 | border='0' height='32' alt='Next Page' width='32' /></A></td> | |
32 | <td align="center" width="100%">Python Library Reference</td> | |
33 | <td class='online-navigation'><a rel="contents" title="Table of Contents" | |
34 | href="contents.html"><img src='../icons/contents.png' | |
35 | border='0' height='32' alt='Contents' width='32' /></A></td> | |
36 | <td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png' | |
37 | border='0' height='32' alt='Module Index' width='32' /></a></td> | |
38 | <td class='online-navigation'><a rel="index" title="Index" | |
39 | href="genindex.html"><img src='../icons/index.png' | |
40 | border='0' height='32' alt='Index' width='32' /></A></td> | |
41 | </tr></table> | |
42 | <div class='online-navigation'> | |
43 | <b class="navlabel">Previous:</b> | |
44 | <a class="sectref" rel="prev" href="module-Queue.html">7.8 Queue </A> | |
45 | <b class="navlabel">Up:</b> | |
46 | <a class="sectref" rel="parent" href="module-Queue.html">7.8 Queue </A> | |
47 | <b class="navlabel">Next:</b> | |
48 | <a class="sectref" rel="next" href="module-mmap.html">7.9 mmap </A> | |
49 | </div> | |
50 | <hr /></div> | |
51 | </DIV> | |
52 | <!--End of Navigation Panel--> | |
53 | ||
54 | <H2><A NAME="SECTION009810000000000000000"></A> | |
55 | <A NAME="QueueObjects"></A> | |
56 | <BR> | |
57 | 7.8.1 Queue Objects | |
58 | </H2> | |
59 | ||
60 | <P> | |
61 | Class <tt class="class">Queue</tt> implements queue objects and has the methods | |
62 | described below. This class can be derived from in order to implement | |
63 | other queue organizations (e.g. stack) but the inheritable interface | |
64 | is not described here. See the source code for details. The public | |
65 | methods are: | |
66 | ||
67 | <P> | |
68 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> | |
69 | <td><nobr><b><tt id='l2h-2755' xml:id='l2h-2755' class="method">qsize</tt></b>(</nobr></td> | |
70 | <td><var></var>)</td></tr></table></dt> | |
71 | <dd> | |
72 | Return the approximate size of the queue. Because of multithreading | |
73 | semantics, this number is not reliable. | |
74 | </dl> | |
75 | ||
76 | <P> | |
77 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> | |
78 | <td><nobr><b><tt id='l2h-2756' xml:id='l2h-2756' class="method">empty</tt></b>(</nobr></td> | |
79 | <td><var></var>)</td></tr></table></dt> | |
80 | <dd> | |
81 | Return <code>True</code> if the queue is empty, <code>False</code> otherwise. | |
82 | Because of multithreading semantics, this is not reliable. | |
83 | </dl> | |
84 | ||
85 | <P> | |
86 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> | |
87 | <td><nobr><b><tt id='l2h-2757' xml:id='l2h-2757' class="method">full</tt></b>(</nobr></td> | |
88 | <td><var></var>)</td></tr></table></dt> | |
89 | <dd> | |
90 | Return <code>True</code> if the queue is full, <code>False</code> otherwise. | |
91 | Because of multithreading semantics, this is not reliable. | |
92 | </dl> | |
93 | ||
94 | <P> | |
95 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> | |
96 | <td><nobr><b><tt id='l2h-2758' xml:id='l2h-2758' class="method">put</tt></b>(</nobr></td> | |
97 | <td><var>item</var><big>[</big><var>, block</var><big>[</big><var>, timeout</var><big>]</big><var></var><big>]</big><var></var>)</td></tr></table></dt> | |
98 | <dd> | |
99 | Put <var>item</var> into the queue. If optional args <var>block</var> is true | |
100 | and <var>timeout</var> is None (the default), block if necessary until a | |
101 | free slot is available. If <var>timeout</var> is a positive number, it | |
102 | blocks at most <var>timeout</var> seconds and raises the <tt class="exception">Full</tt> | |
103 | exception if no free slot was available within that time. | |
104 | Otherwise (<var>block</var> is false), put an item on the queue if a free | |
105 | slot is immediately available, else raise the <tt class="exception">Full</tt> | |
106 | exception (<var>timeout</var> is ignored in that case). | |
107 | ||
108 | <P> | |
109 | ||
110 | <span class="versionnote">New in version 2.3: | |
111 | the timeout parameter.</span> | |
112 | ||
113 | <P> | |
114 | </dl> | |
115 | ||
116 | <P> | |
117 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> | |
118 | <td><nobr><b><tt id='l2h-2759' xml:id='l2h-2759' class="method">put_nowait</tt></b>(</nobr></td> | |
119 | <td><var>item</var>)</td></tr></table></dt> | |
120 | <dd> | |
121 | Equivalent to <code>put(<var>item</var>, False)</code>. | |
122 | </dl> | |
123 | ||
124 | <P> | |
125 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> | |
126 | <td><nobr><b><tt id='l2h-2760' xml:id='l2h-2760' class="method">get</tt></b>(</nobr></td> | |
127 | <td><var></var><big>[</big><var>block</var><big>[</big><var>, timeout</var><big>]</big><var></var><big>]</big><var></var>)</td></tr></table></dt> | |
128 | <dd> | |
129 | Remove and return an item from the queue. If optional args | |
130 | <var>block</var> is true and <var>timeout</var> is None (the default), | |
131 | block if necessary until an item is available. If <var>timeout</var> is | |
132 | a positive number, it blocks at most <var>timeout</var> seconds and raises | |
133 | the <tt class="exception">Empty</tt> exception if no item was available within that | |
134 | time. Otherwise (<var>block</var> is false), return an item if one is | |
135 | immediately available, else raise the <tt class="exception">Empty</tt> exception | |
136 | (<var>timeout</var> is ignored in that case). | |
137 | ||
138 | <P> | |
139 | ||
140 | <span class="versionnote">New in version 2.3: | |
141 | the timeout parameter.</span> | |
142 | ||
143 | <P> | |
144 | </dl> | |
145 | ||
146 | <P> | |
147 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> | |
148 | <td><nobr><b><tt id='l2h-2761' xml:id='l2h-2761' class="method">get_nowait</tt></b>(</nobr></td> | |
149 | <td><var></var>)</td></tr></table></dt> | |
150 | <dd> | |
151 | Equivalent to <code>get(False)</code>. | |
152 | </dl> | |
153 | ||
154 | <DIV CLASS="navigation"> | |
155 | <div class='online-navigation'> | |
156 | <p></p><hr /> | |
157 | <table align="center" width="100%" cellpadding="0" cellspacing="2"> | |
158 | <tr> | |
159 | <td class='online-navigation'><a rel="prev" title="7.8 Queue " | |
160 | href="module-Queue.html"><img src='../icons/previous.png' | |
161 | border='0' height='32' alt='Previous Page' width='32' /></A></td> | |
162 | <td class='online-navigation'><a rel="parent" title="7.8 Queue " | |
163 | href="module-Queue.html"><img src='../icons/up.png' | |
164 | border='0' height='32' alt='Up One Level' width='32' /></A></td> | |
165 | <td class='online-navigation'><a rel="next" title="7.9 mmap " | |
166 | href="module-mmap.html"><img src='../icons/next.png' | |
167 | border='0' height='32' alt='Next Page' width='32' /></A></td> | |
168 | <td align="center" width="100%">Python Library Reference</td> | |
169 | <td class='online-navigation'><a rel="contents" title="Table of Contents" | |
170 | href="contents.html"><img src='../icons/contents.png' | |
171 | border='0' height='32' alt='Contents' width='32' /></A></td> | |
172 | <td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png' | |
173 | border='0' height='32' alt='Module Index' width='32' /></a></td> | |
174 | <td class='online-navigation'><a rel="index" title="Index" | |
175 | href="genindex.html"><img src='../icons/index.png' | |
176 | border='0' height='32' alt='Index' width='32' /></A></td> | |
177 | </tr></table> | |
178 | <div class='online-navigation'> | |
179 | <b class="navlabel">Previous:</b> | |
180 | <a class="sectref" rel="prev" href="module-Queue.html">7.8 Queue </A> | |
181 | <b class="navlabel">Up:</b> | |
182 | <a class="sectref" rel="parent" href="module-Queue.html">7.8 Queue </A> | |
183 | <b class="navlabel">Next:</b> | |
184 | <a class="sectref" rel="next" href="module-mmap.html">7.9 mmap </A> | |
185 | </div> | |
186 | </div> | |
187 | <hr /> | |
188 | <span class="release-info">Release 2.4.2, documentation updated on 28 September 2005.</span> | |
189 | </DIV> | |
190 | <!--End of Navigation Panel--> | |
191 | <ADDRESS> | |
192 | See <i><a href="about.html">About this document...</a></i> for information on suggesting changes. | |
193 | </ADDRESS> | |
194 | </BODY> | |
195 | </HTML> |