When used with asyncio.Future, WaitIterator may skip indices in some
cases. This is caused by multiple _return_result calls after another,
without having the chain_future call finish in between. This is fixed
here by not hanging on to the _running_future anymore, which forces
subsequent _return_result calls to add to _finished, instead of causing
the previous result to be silently dropped.
Fixes #2034
self._running_future = Future()
if self._finished:
- self._return_result(self._finished.popleft())
+ return self._return_result(self._finished.popleft())
return self._running_future
raise Exception("no future is running")
chain_future(done, self._running_future)
+ res = self._running_future
+ self._running_future = None
self.current_future = done
self.current_index = self._unfinished.pop(done)
+ return res
+
def __aiter__(self) -> typing.AsyncIterator:
return self