Skip to content

Commit 9684312

Browse files
committed
refactor: remove else part of for ... else in @Retry
Actually we don't need it, because we have `return` if target function was run without exceptions.
1 parent a811e1d commit 9684312

1 file changed

Lines changed: 8 additions & 7 deletions

File tree

tion_btle/tion.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,15 @@ async def wrapper(*args, **kwargs):
3737
pass
3838
if delay > 0:
3939
await asyncio.sleep(delay)
40-
else:
41-
_LOGGER.critical("Retry limit (%d) exceeded for %s(%s, %s)", retries, f.__name__, args, kwargs)
42-
if _LOGGER.level > logging.INFO and last_info_exception is not None:
43-
_LOGGER.critical(f"Last exception was {last_info_exception}")
44-
elif _LOGGER.level > logging.WARNING and last_warning_exception is not None:
45-
_LOGGER.critical(f"Last exception was {last_warning_exception}")
4640

47-
raise MaxTriesExceededError
41+
_LOGGER.critical("Retry limit (%d) exceeded for %s(%s, %s)", retries, f.__name__, args, kwargs)
42+
if _LOGGER.level > logging.INFO and last_info_exception is not None:
43+
_LOGGER.critical(f"Last exception was {last_info_exception}")
44+
elif _LOGGER.level > logging.WARNING and last_warning_exception is not None:
45+
_LOGGER.critical(f"Last exception was {last_warning_exception}")
46+
47+
raise MaxTriesExceededError
48+
4849
return wrapper
4950
return decor
5051

0 commit comments

Comments
 (0)