From 153127e02818154ab6977e9a4a169bb60f8d2f09 Mon Sep 17 00:00:00 2001 From: Daniil Fajnberg Date: Wed, 30 Mar 2022 11:47:15 +0200 Subject: [PATCH] lock before gathering meta tasks --- src/asyncio_taskpool/pool.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/asyncio_taskpool/pool.py b/src/asyncio_taskpool/pool.py index 2267c9f..0919593 100644 --- a/src/asyncio_taskpool/pool.py +++ b/src/asyncio_taskpool/pool.py @@ -607,6 +607,7 @@ class TaskPool(BaseTaskPool): Raises: `PoolStillUnlocked`: The pool has not been locked yet. """ + self.lock() not_cancelled_meta_tasks = (task for task_set in self._group_meta_tasks_running.values() for task in task_set) with suppress(CancelledError): await gather(*self._meta_tasks_cancelled, *not_cancelled_meta_tasks, return_exceptions=return_exceptions)