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)
| 336 | self._count.release() |
| 337 | |
| 338 | def get(self, block=True, timeout=None): |
| 339 | '''Remove and return an item from the queue. |
| 340 | |
| 341 | If optional args 'block' is true and 'timeout' is None (the default), |
| 342 | block if necessary until an item is available. If 'timeout' is |
| 343 | a non-negative number, it blocks at most 'timeout' seconds and raises |
| 344 | the Empty exception if no item was available within that time. |
| 345 | Otherwise ('block' is false), return an item if one is immediately |
| 346 | available, else raise the Empty exception ('timeout' is ignored |
| 347 | in that case). |
| 348 | ''' |
| 349 | if timeout is not None and timeout < 0: |
| 350 | raise ValueError("'timeout' must be a non-negative number") |
| 351 | if not self._count.acquire(block, timeout): |
| 352 | raise Empty |
| 353 | return self._queue.popleft() |
| 354 | |
| 355 | def put_nowait(self, item): |
| 356 | '''Put an item into the queue without blocking. |