| 851 | return self |
| 852 | |
| 853 | def next(self, timeout=None): |
| 854 | with self._cond: |
| 855 | try: |
| 856 | item = self._items.popleft() |
| 857 | except IndexError: |
| 858 | if self._index == self._length: |
| 859 | self._pool = None |
| 860 | raise StopIteration from None |
| 861 | self._cond.wait(timeout) |
| 862 | try: |
| 863 | item = self._items.popleft() |
| 864 | except IndexError: |
| 865 | if self._index == self._length: |
| 866 | self._pool = None |
| 867 | raise StopIteration from None |
| 868 | raise TimeoutError from None |
| 869 | |
| 870 | success, value = item |
| 871 | if success: |
| 872 | return value |
| 873 | raise value |
| 874 | |
| 875 | __next__ = next # XXX |
| 876 | |