MCPcopy Index your code
hub / github.com/python/cpython / get

Method get

Lib/queue.py:177–215  ·  view source on GitHub ↗

Remove and return an item from the queue. If optional args 'block' is true and 'timeout' is None (the default), block if necessary until an item is available. If 'timeout' is a non-negative number, it blocks at most 'timeout' seconds and raises the Empty exception if

(self, block=True, timeout=None)

Source from the content-addressed store, hash-verified

175 self.not_empty.notify()
176
177 def get(self, block=True, timeout=None):
178 '''Remove and return an item from the queue.
179
180 If optional args 'block' is true and 'timeout' is None (the default),
181 block if necessary until an item is available. If 'timeout' is
182 a non-negative number, it blocks at most 'timeout' seconds and raises
183 the Empty exception if no item was available within that time.
184 Otherwise ('block' is false), return an item if one is immediately
185 available, else raise the Empty exception ('timeout' is ignored
186 in that case).
187
188 Raises ShutDown if the queue has been shut down and is empty,
189 or if the queue has been shut down immediately.
190 '''
191 with self.not_empty:
192 if self.is_shutdown and not self._qsize():
193 raise ShutDown
194 if not block:
195 if not self._qsize():
196 raise Empty
197 elif timeout is None:
198 while not self._qsize():
199 self.not_empty.wait()
200 if self.is_shutdown and not self._qsize():
201 raise ShutDown
202 elif timeout < 0:
203 raise ValueError("'timeout' must be a non-negative number")
204 else:
205 endtime = time() + timeout
206 while not self._qsize():
207 remaining = endtime - time()
208 if remaining <= 0.0:
209 raise Empty
210 self.not_empty.wait(remaining)
211 if self.is_shutdown and not self._qsize():
212 raise ShutDown
213 item = self._get()
214 self.not_full.notify()
215 return item
216
217 def put_nowait(self, item):
218 ''&#x27;Put an item into the queue without blocking.

Callers 15

testFunction · 0.95
get_nowaitMethod · 0.95
testFunction · 0.45
glossary_searchFunction · 0.45
id_forMethod · 0.45
add_annotationsFunction · 0.45
android_envFunction · 0.45
parse_argsFunction · 0.45
fetch_releaseFunction · 0.45
updated_envFunction · 0.45
calculate_node_pathFunction · 0.45

Calls 5

_qsizeMethod · 0.95
_getMethod · 0.95
timeClass · 0.90
waitMethod · 0.45
notifyMethod · 0.45

Tested by

no test coverage detected