Skip to content

Commit 4a72b8f

Browse files
committed
uhhh.... funny api
1 parent fe31cdf commit 4a72b8f

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

async_utils/bg_tasks.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ async def __aenter__(self: Self) -> Self:
4444
return self
4545

4646
async def __aexit__(self, exc_type: type[Exception], exc: Exception, tb: TracebackType):
47-
_done, _pending = await asyncio.wait(self._tasks, timeout=self._exit_timeout)
48-
for task in _pending:
49-
task.cancel()
47+
if tsks := self._tasks.copy():
48+
_done, _pending = await asyncio.wait(tsks, timeout=self._exit_timeout)
49+
for task in _pending:
50+
task.cancel()

0 commit comments

Comments
 (0)