Drop stream exhaustion; no longer needed

stream_contexts
Tyler Goodlet 2021-04-28 11:38:10 -04:00
parent 3e19fd311b
commit ad9256bcdb
1 changed files with 5 additions and 11 deletions

View File

@ -98,17 +98,11 @@ async def exhaust_portal(
"""
try:
log.debug(f"Waiting on final result from {actor.uid}")
final = res = await portal.result()
# if it's an async-gen then alert that we're cancelling it
if inspect.isasyncgen(res):
final = []
log.warning(
f"Blindly consuming asyncgen for {actor.uid}")
with trio.fail_after(1):
async with aclosing(res) as agen:
async for item in agen:
log.debug(f"Consuming item {item}")
final.append(item)
# XXX: streams should never be reaped here since they should
# always be established and shutdown using a context manager api
final = await portal.result()
except (Exception, trio.MultiError) as err:
# we reraise in the parent task via a ``trio.MultiError``
return err