From 6803891bd796a09b263d2bccafa1908d2176f2c7 Mon Sep 17 00:00:00 2001 From: Tyler Goodlet Date: Wed, 24 Nov 2021 12:12:21 -0500 Subject: [PATCH] Collect `asyncio` task exceptions to avoid warning msg --- tractor/to_asyncio.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tractor/to_asyncio.py b/tractor/to_asyncio.py index 4e33e68..b6ec90e 100644 --- a/tractor/to_asyncio.py +++ b/tractor/to_asyncio.py @@ -136,6 +136,13 @@ def _run_asyncio_task( nonlocal aio_err aio_err = from_aio._err + # only to avoid ``asyncio`` complaining about uncaptured + # task exceptions + try: + task.exception() + except BaseException as terr: + assert type(terr) is type(aio_err), 'Asyncio task error mismatch?' + if aio_err is not None: if type(aio_err) is CancelledError: log.cancel("infected task was cancelled")