Skip to content

Commit 701c798

Browse files
committed
Added docs
1 parent 3aaa478 commit 701c798

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

packages/service-library/src/servicelib/redis/_semaphore_decorator.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,10 @@ async def _managed_semaphore_execution(
4343
raise SemaphoreAcquisitionError(name=semaphore_key, capacity=semaphore.capacity)
4444

4545
try:
46-
# Use TaskGroup for proper exception propagation
46+
# NOTE: Use TaskGroup for proper exception propagation, this ensures that in case of error the context manager will be properly exited
47+
# and the semaphore released.
48+
# If we use create_task() directly, exceptions in the task are not propagated to the parent task
49+
# and the context manager may never exit, leading to semaphore leaks.
4750
async with asyncio.TaskGroup() as tg:
4851
started_event = asyncio.Event()
4952

0 commit comments

Comments
 (0)