File tree Expand file tree Collapse file tree 1 file changed +5
-8
lines changed
packages/service-library/src/servicelib/redis Expand file tree Collapse file tree 1 file changed +5
-8
lines changed Original file line number Diff line number Diff line change @@ -183,11 +183,9 @@ async def acquire(self) -> bool:
183183 if timeout_seconds is not None :
184184 elapsed = asyncio .get_event_loop ().time () - start_time
185185 if elapsed >= timeout_seconds :
186- if self .blocking :
187- raise SemaphoreAcquisitionError (
188- name = self .key , capacity = self .capacity
189- )
190- return False
186+ raise SemaphoreAcquisitionError (
187+ name = self .key , capacity = self .capacity
188+ )
191189
192190 # Wait a bit before retrying
193191 await asyncio .sleep (0.1 )
@@ -364,9 +362,8 @@ async def _wrapper(*args: P.args, **kwargs: P.kwargs) -> R:
364362 blocking_timeout = blocking_timeout ,
365363 )
366364
367- # Acquire the semaphore
368- if not await semaphore .acquire () and not blocking :
369- # Non-blocking mode, semaphore not available
365+ # Acquire the semaphore first
366+ if not await semaphore .acquire ():
370367 raise SemaphoreAcquisitionError (
371368 name = semaphore_key , capacity = semaphore_capacity
372369 )
You can’t perform that action at this time.
0 commit comments