Skip to content

Commit

Permalink
Empty check before pop (#4929)
Browse files Browse the repository at this point in the history
# Check whether 'other' is empty before popping

This PR could fix a potential 'popping empty set' error.

Co-authored-by: Junlin Zhou <jlzhou@zjuici.com>
  • Loading branch information
2 people authored and vowelparrot committed May 24, 2023
1 parent f64a207 commit 4392743
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion langchain/callbacks/streaming_aiter.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ async def aiter(self) -> AsyncIterator[str]:
)

# Cancel the other task
other.pop().cancel()
if other:
other.pop().cancel()

# Extract the value of the first completed task
token_or_done = cast(Union[str, Literal[True]], done.pop().result())
Expand Down

0 comments on commit 4392743

Please sign in to comment.