@@ -141,9 +141,7 @@ def exponential_sleep_generator(initial, maximum, multiplier=_DEFAULT_DELAY_MULT
141141 delay = delay * multiplier
142142
143143
144- def retry_target (
145- target , predicate , sleep_generator , deadline , on_error = None , strict_deadline = False
146- ):
144+ def retry_target (target , predicate , sleep_generator , deadline , on_error = None ):
147145 """Call a function and retry if it fails.
148146
149147 This is the lowest-level retry helper. Generally, you'll use the
@@ -157,13 +155,12 @@ def retry_target(
157155 It should return True to retry or False otherwise.
158156 sleep_generator (Iterable[float]): An infinite iterator that determines
159157 how long to sleep between retries.
160- deadline (float): How long to keep retrying the target.
158+ deadline (float): How long to keep retrying the target. The last sleep
159+ period is shortened as necessary, so that the last retry runs at
160+ ``deadline`` (and not considerably beyond it).
161161 on_error (Callable[Exception]): A function to call while processing a
162162 retryable exception. Any error raised by this function will *not*
163163 be caught.
164- strict_deadline (bool): If :data:`True`, the last retry will run at
165- ``deadline``, shortening the last sleep interval as necessary.
166- Defaults to :data:`False`.
167164
168165 Returns:
169166 Any: the return value of the target function.
@@ -208,7 +205,7 @@ def retry_target(
208205 ),
209206 last_exc ,
210207 )
211- elif strict_deadline :
208+ else :
212209 time_to_deadline = (deadline_datetime - now ).total_seconds ()
213210 sleep = min (time_to_deadline , sleep )
214211
@@ -237,10 +234,9 @@ class Retry(object):
237234 must be greater than 0.
238235 maximum (float): The maximum amout of time to delay in seconds.
239236 multiplier (float): The multiplier applied to the delay.
240- deadline (float): How long to keep retrying in seconds.
241- strict_deadline (bool): If :data:`True`, the last retry will run at
242- ``deadline``, shortening the last sleep interval as necessary.
243- Defaults to :data:`False`.
237+ deadline (float): How long to keep retrying in seconds. The last sleep
238+ period is shortened as necessary, so that the last retry runs at
239+ ``deadline`` (and not considerably beyond it).
244240 """
245241
246242 def __init__ (
@@ -251,15 +247,13 @@ def __init__(
251247 multiplier = _DEFAULT_DELAY_MULTIPLIER ,
252248 deadline = _DEFAULT_DEADLINE ,
253249 on_error = None ,
254- strict_deadline = False ,
255250 ):
256251 self ._predicate = predicate
257252 self ._initial = initial
258253 self ._multiplier = multiplier
259254 self ._maximum = maximum
260255 self ._deadline = deadline
261256 self ._on_error = on_error
262- self ._strict_deadline = strict_deadline
263257
264258 def __call__ (self , func , on_error = None ):
265259 """Wrap a callable with retry behavior.
@@ -290,19 +284,15 @@ def retry_wrapped_func(*args, **kwargs):
290284 sleep_generator ,
291285 self ._deadline ,
292286 on_error = on_error ,
293- strict_deadline = self ._strict_deadline
294287 )
295288
296289 return retry_wrapped_func
297290
298- def with_deadline (self , deadline , strict_deadline = False ):
291+ def with_deadline (self , deadline ):
299292 """Return a copy of this retry with the given deadline.
300293
301294 Args:
302295 deadline (float): How long to keep retrying.
303- strict_deadline (bool): If :data:`True`, the last retry will run at
304- ``deadline``, shortening the last sleep interval as necessary.
305- Defaults to :data:`False`.
306296
307297 Returns:
308298 Retry: A new retry instance with the given deadline.
@@ -314,7 +304,6 @@ def with_deadline(self, deadline, strict_deadline=False):
314304 multiplier = self ._multiplier ,
315305 deadline = deadline ,
316306 on_error = self ._on_error ,
317- strict_deadline = strict_deadline ,
318307 )
319308
320309 def with_predicate (self , predicate ):
@@ -334,7 +323,6 @@ def with_predicate(self, predicate):
334323 multiplier = self ._multiplier ,
335324 deadline = self ._deadline ,
336325 on_error = self ._on_error ,
337- strict_deadline = self ._strict_deadline ,
338326 )
339327
340328 def with_delay (self , initial = None , maximum = None , multiplier = None ):
@@ -356,20 +344,17 @@ def with_delay(self, initial=None, maximum=None, multiplier=None):
356344 multiplier = multiplier if maximum is not None else self ._multiplier ,
357345 deadline = self ._deadline ,
358346 on_error = self ._on_error ,
359- strict_deadline = self ._strict_deadline ,
360347 )
361348
362349 def __str__ (self ):
363350 return (
364351 "<Retry predicate={}, initial={:.1f}, maximum={:.1f}, "
365- "multiplier={:.1f}, deadline={:.1f}, on_error={}, "
366- "strict_deadline={}>" .format (
352+ "multiplier={:.1f}, deadline={:.1f}, on_error={}>" .format (
367353 self ._predicate ,
368354 self ._initial ,
369355 self ._maximum ,
370356 self ._multiplier ,
371357 self ._deadline ,
372358 self ._on_error ,
373- self ._strict_deadline ,
374359 )
375360 )
0 commit comments