File tree Expand file tree Collapse file tree 1 file changed +12
-3
lines changed
packages/service-library/src/servicelib/redis Expand file tree Collapse file tree 1 file changed +12
-3
lines changed Original file line number Diff line number Diff line change 1818)
1919from ._errors import (
2020 SemaphoreAcquisitionError ,
21+ SemaphoreLostError ,
22+ SemaphoreNotAcquiredError ,
2123)
2224from ._semaphore import DistributedSemaphore
2325
@@ -68,14 +70,21 @@ async def _periodic_renewer() -> None:
6870 await cancel_wait_task (renewal_task , max_delay = None )
6971
7072 except BaseExceptionGroup as eg :
71- # Re-raise the first exception in the group
72- raise eg .exceptions [0 ] from eg
73+ semaphore_lost_errors , other_errors = eg .split (SemaphoreLostError )
74+ # If there are any other errors, re-raise them
75+ if other_errors :
76+ assert len (other_errors .exceptions ) == 1 # nosec
77+ raise other_errors .exceptions [0 ] from eg
78+
79+ assert semaphore_lost_errors is not None # nosec
80+ assert len (semaphore_lost_errors .exceptions ) == 1 # nosec
81+ raise semaphore_lost_errors .exceptions [0 ] from eg
7382
7483 finally :
7584 # Always attempt to release the semaphore
7685 try :
7786 await semaphore .release ()
78- except Exception as exc :
87+ except SemaphoreNotAcquiredError as exc :
7988 _logger .exception (
8089 ** create_troubleshootting_log_kwargs (
8190 "Unexpected error while releasing semaphore" ,
You can’t perform that action at this time.
0 commit comments