[BACKEND] Debug log exception on retry (#957)
Help diagnose retry errors better
This commit is contained in:
parent
c622cf68b5
commit
ad72e1a6de
1 changed files with 4 additions and 2 deletions
|
|
@ -34,12 +34,14 @@ def retry(times: int, exceptions: Tuple[Type[Exception], ...], wait_sec: int = 5
|
||||||
while attempt < times:
|
while attempt < times:
|
||||||
try:
|
try:
|
||||||
return func(*args, **kwargs)
|
return func(*args, **kwargs)
|
||||||
except exceptions:
|
except exceptions as exc:
|
||||||
logger.debug(
|
logger.debug(
|
||||||
"Exception thrown when attempting to run %s, attempt %d of %d",
|
"Exception thrown when attempting to run %s, attempt %d of %d\n"
|
||||||
|
"Exception:\n%s",
|
||||||
func.__name__,
|
func.__name__,
|
||||||
attempt + 1,
|
attempt + 1,
|
||||||
times,
|
times,
|
||||||
|
str(exc),
|
||||||
)
|
)
|
||||||
attempt += 1
|
attempt += 1
|
||||||
sleep(wait_sec)
|
sleep(wait_sec)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue