File tree Expand file tree Collapse file tree 1 file changed +9
-8
lines changed Expand file tree Collapse file tree 1 file changed +9
-8
lines changed Original file line number Diff line number Diff line change @@ -381,23 +381,24 @@ async def __anext__(self) -> T:
381381 # Check if another peer produced an item while we were waiting for the lock
382382 if not next_node :
383383 await self ._extend_buffer (next_node )
384- if not next_node :
385- raise StopAsyncIteration ()
386384 # for any other TeePeer, the node is already some [value, [...]]
387385 value , self ._buffer = next_node # type: ignore
388386 return value
389387
390388 async def _extend_buffer (self , next_node : "_TeeNode[T]" ) -> None :
391389 """Extend the buffer by fetching a new item from the iterable"""
392390 try :
391+ # another peer may fill the buffer while we wait here
393392 next_value = await self ._iterator .__anext__ ()
394393 except StopAsyncIteration :
395- return
396- # another peer may have filled the buffer while we waited
397- # seek the last node that needs to be filled
398- while next_node :
399- _ , next_node = next_node # type: ignore
400- next_node [:] = next_value , []
394+ # no one else managed to fetch a value either
395+ if not next_node :
396+ raise
397+ else :
398+ # seek the last node that needs to be filled
399+ while next_node :
400+ _ , next_node = next_node # type: ignore
401+ next_node [:] = next_value , []
401402
402403 async def aclose (self ) -> None :
403404 self ._tee_peers .discard (self ._tee_idx )
You can’t perform that action at this time.
0 commit comments