From 569af7506940c925ca5697d0f15f732d92e17896 Mon Sep 17 00:00:00 2001 From: richardsheridan Date: Sun, 30 Jul 2023 09:55:55 -0400 Subject: [PATCH] add extra assertion for deadlock prevention --- trio_parallel/_impl.py | 1 + 1 file changed, 1 insertion(+) diff --git a/trio_parallel/_impl.py b/trio_parallel/_impl.py index 59847bf4..d25a6293 100644 --- a/trio_parallel/_impl.py +++ b/trio_parallel/_impl.py @@ -185,6 +185,7 @@ async def _aclose(self): self._lifetime.waiting_task = trio.lowlevel.current_task() with trio.CancelScope(shield=True): if self._lifetime.calc_running() != 0: + assert self is not get_default_context() await trio.sleep_forever() # woken by self._lifetime.__aexit__ await trio.to_thread.run_sync( self._worker_cache.shutdown, self.grace_period