File tree Expand file tree Collapse file tree 1 file changed +11
-9
lines changed
packages/service-library/src/servicelib/redis Expand file tree Collapse file tree 1 file changed +11
-9
lines changed Original file line number Diff line number Diff line change 2222 stop_never ,
2323 wait_random_exponential ,
2424)
25+ from tenacity .stop import stop_base
2526
2627from ._client import RedisClientSDK
2728from ._constants import (
@@ -206,18 +207,19 @@ async def acquire(self) -> bool:
206207
207208 ttl_seconds = int (self .ttl .total_seconds ())
208209
210+ # Determine retry stop condition based on blocking configuration
211+ stop_condition : stop_base = stop_after_delay (0 )
212+ if self .blocking :
213+ stop_condition = (
214+ stop_after_delay (self .blocking_timeout )
215+ if self .blocking_timeout
216+ else stop_never
217+ )
218+
209219 try :
210220
211221 @retry (
212- stop = (
213- stop_after_delay (0 )
214- if not self .blocking
215- else (
216- stop_after_delay (self .blocking_timeout )
217- if self .blocking_timeout
218- else stop_never
219- )
220- ),
222+ stop = stop_condition ,
221223 wait = wait_random_exponential (min = 0.1 , max = 0.5 ),
222224 retry = retry_if_exception_type (redis .exceptions .TimeoutError ),
223225 )
You can’t perform that action at this time.
0 commit comments