From e86576b05107957ee44ab4d7655f5264579542a1 Mon Sep 17 00:00:00 2001 From: "Maarten A. Breddels" Date: Fri, 5 Mar 2021 13:36:12 +0100 Subject: [PATCH] fix: ensure_async should not silently eat errors and return the coro --- nbclient/util.py | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/nbclient/util.py b/nbclient/util.py index 9ac4e219..30db98a0 100644 --- a/nbclient/util.py +++ b/nbclient/util.py @@ -81,13 +81,6 @@ async def ensure_async(obj: Union[Awaitable, Any]) -> Any: and await it if it was not already awaited. """ if inspect.isawaitable(obj): - try: - result = await obj - except RuntimeError as e: - if str(e) == 'cannot reuse already awaited coroutine': - # obj is already the coroutine's result - return obj - raise - return result - # obj doesn't need to be awaited - return obj + return await obj + else: + return obj