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
)
| 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. |
no test coverage detected