Always raise asyncio errors

msgspec_infect_asyncio
Tyler Goodlet 2021-09-07 16:59:11 -04:00
parent d6ddc47e58
commit 57edf481e8
1 changed files with 4 additions and 17 deletions

View File

@ -158,28 +158,15 @@ async def run_task(
with cs:
return await from_aio.receive()
if cs.cancelled_caught:
# always raise from any captured asyncio error
if from_aio._err:
raise from_aio._err
# Do we need this?
except Exception as err:
aio_err = from_aio._err
if aio_err is not None:
# always raise from any captured asyncio error
raise err from aio_err
else:
raise
except trio.Cancelled:
if not task.done():
task.cancel()
raise
finally:
if from_aio._err:
raise from_aio._err
# TODO: explicit api for the streaming case where
# we pull from the mem chan in an async generator?