From 8bc645ff453920eca626d1a85440b83ab8d6c12c Mon Sep 17 00:00:00 2001 From: Stephen Macke Date: Thu, 25 May 2023 10:23:50 -0700 Subject: [PATCH] dont allow repeated patching --- jupyter_core/utils/patched_nest_asyncio.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/jupyter_core/utils/patched_nest_asyncio.py b/jupyter_core/utils/patched_nest_asyncio.py index 8555847..5c19c33 100644 --- a/jupyter_core/utils/patched_nest_asyncio.py +++ b/jupyter_core/utils/patched_nest_asyncio.py @@ -29,6 +29,8 @@ def step(task, exc=None): curr_tasks[task._loop] = curr_task Task = asyncio.Task + if hasattr(Task, '_nest_patched'): + return if sys.version_info >= (3, 7, 0): def enter_task(loop, task): @@ -52,3 +54,4 @@ def leave_task(loop, task): except AttributeError: step_orig = Task._step # type: ignore Task._step = step # type: ignore + Task._nest_patched = True # type: ignore