mirror of
https://github.com/meeb/tubesync.git
synced 2025-06-22 21:16:38 +00:00
Better handling of large retries
This commit is contained in:
parent
93b5ef7d43
commit
328682160e
@ -74,10 +74,13 @@ def exponential_backoff(task_func=None, /, *args, **kwargs):
|
|||||||
try:
|
try:
|
||||||
return fn(*a, **kwa)
|
return fn(*a, **kwa)
|
||||||
except Exception as exc:
|
except Exception as exc:
|
||||||
attempt = 1
|
for attempt in range(1, 1_001):
|
||||||
while task.retry_delay <= backoff(attempt):
|
if backoff(attempt) > task.retry_delay:
|
||||||
attempt += 1
|
task.retry_delay = backoff(attempt)
|
||||||
task.retry_delay = backoff(attempt)
|
break
|
||||||
|
# insanity, but handle it anyway
|
||||||
|
if 1_000 == attempt:
|
||||||
|
task.retry_delay = backoff(attempt)
|
||||||
raise exc
|
raise exc
|
||||||
kwargs.update(dict(
|
kwargs.update(dict(
|
||||||
context=True,
|
context=True,
|
||||||
|
Loading…
Reference in New Issue
Block a user