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

Method get

Lib/concurrent/interpreters/_queues.py:240–270  ·  view source on GitHub ↗

Return the next object from the queue. If "block" is true, this blocks while the queue is empty. If the next item's original interpreter has been destroyed then the "next object" is determined by the value of the "unbounditems" argument to put().

(self, block=True, timeout=None, *,
            _delay=10 / 1000,  # 10 milliseconds
            )

Source from the content-addressed store, hash-verified

238 _queues.put(self._id, obj, unboundop)
239
240 def get(self, block=True, timeout=None, *,
241 _delay=10 / 1000, # 10 milliseconds
242 ):
243 """Return the next object from the queue.
244
245 If "block" is true, this blocks while the queue is empty.
246
247 If the next item's original interpreter has been destroyed
248 then the "next object" is determined by the value of the
249 "unbounditems" argument to put().
250 """
251 if not block:
252 return self.get_nowait()
253 if timeout is not None:
254 timeout = int(timeout)
255 if timeout < 0:
256 raise ValueError(f'timeout value must be non-negative')
257 end = time.time() + timeout
258 while True:
259 try:
260 obj, unboundop = _queues.get(self._id)
261 except QueueEmpty:
262 if timeout is not None and time.time() >= end:
263 raise # re-raise
264 time.sleep(_delay)
265 else:
266 break
267 if unboundop is not None:
268 assert obj is None, repr(obj)
269 return _resolve_unbound(unboundop)
270 return obj
271
272 def get_nowait(self):
273 """Return the next object from the channel.

Callers 5

get_nowaitMethod · 0.45
runMethod · 0.45
_workerFunction · 0.45
_process_workerFunction · 0.45

Calls 4

get_nowaitMethod · 0.95
_resolve_unboundFunction · 0.70
timeMethod · 0.45
sleepMethod · 0.45

Tested by

no test coverage detected