Skip to content

Commit

Permalink
Fix confusing traceback when calling wait_stream on a empty stream
Browse files Browse the repository at this point in the history
Issue #76, PR #77
  • Loading branch information
vxgmichel authored May 20, 2021
2 parents bc9181c + 0d823f5 commit 871d1b1
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions aiostream/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ async def wait_stream(aiterable):
A StreamEmpty exception is raised if the sequence is empty.
"""
async with streamcontext(aiterable) as streamer:
last_item = unnassigned = object()
async for item in streamer:
item
try:
return item
except NameError:
last_item = item
if last_item is unnassigned:
raise StreamEmpty()
return last_item


# Core objects
Expand Down

0 comments on commit 871d1b1

Please sign in to comment.