diff --git a/async_utils/__init__.py b/async_utils/__init__.py index ec4b4e5..2ebe243 100644 --- a/async_utils/__init__.py +++ b/async_utils/__init__.py @@ -13,4 +13,4 @@ # limitations under the License. -__version__ = "7.0.2" +__version__ = "7.0.3" diff --git a/async_utils/bg_tasks.py b/async_utils/bg_tasks.py index 127c1f8..a39a03a 100644 --- a/async_utils/bg_tasks.py +++ b/async_utils/bg_tasks.py @@ -44,7 +44,8 @@ async def __aenter__(self: Self) -> Self: return self async def __aexit__(self, exc_type: type[Exception], exc: Exception, tb: TracebackType): - if tsks := self._tasks.copy(): + while tsks := self._tasks.copy(): _done, _pending = await asyncio.wait(tsks, timeout=self._exit_timeout) for task in _pending: task.cancel() + await asyncio.sleep(0)