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)
| 92 | self._count.release() |
| 93 | |
| 94 | def get(self, block=True, timeout=None): |
| 95 | """Remove and return an item from the queue. |
| 96 | |
| 97 | If optional args 'block' is true and 'timeout' is None (the default), |
| 98 | block if necessary until an item is available. If 'timeout' is |
| 99 | a non-negative number, it blocks at most 'timeout' seconds and raises |
| 100 | the Empty exception if no item was available within that time. |
| 101 | Otherwise ('block' is false), return an item if one is immediately |
| 102 | available, else raise the Empty exception ('timeout' is ignored |
| 103 | in that case). |
| 104 | """ |
| 105 | if timeout is not None and timeout < 0: |
| 106 | raise ValueError("'timeout' must be a non-negative number") |
| 107 | if not self._count.acquire(block, timeout): |
| 108 | raise queue.Empty |
| 109 | try: |
| 110 | return self._queue.popleft() |
| 111 | except IndexError: |
| 112 | raise queue.Empty |
| 113 | |
| 114 | def wait(self, block=True, timeout=None): |
| 115 | """If queue is empty, wait until an item maybe is available, |
no outgoing calls
no test coverage detected