Skip to content

Commit

Permalink
misc: add option to ignore return code in retry_command
Browse files Browse the repository at this point in the history
  • Loading branch information
pbrezina committed Sep 20, 2024
1 parent 58b5740 commit 57014c5
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions sssd_test_framework/misc/ssh.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ def retry_command(
delay: float = 1,
match_stdout: str | list[str] | None = None,
match_stderr: str | list[str] | None = None,
check_rc: bool = True,
) -> Callable[[Callable[Param, ProcessResult]], Callable[Param, ProcessResult]]:
"""
Decorated function will be retried if its return code is non zero.
Expand All @@ -112,7 +113,8 @@ def retry_command(
:type match_stdout: str | list[str] | None, optional
:param match_stderr: If set, retry only of string is found in stderr, defaults to None
:type match_stderr: str | list[str] | None, optional
:param check_rc: If True and rc == 0, do not retry.
:type check_rc: bool
:return: Decorated function.
:rtype: Callable
"""
Expand Down Expand Up @@ -151,7 +153,7 @@ def wrapper(*args, **kwargs) -> ProcessResult:
stdout = e.stdout
stderr = e.stderr

if rc == 0:
if check_rc and rc == 0:
break

if match_stdout is not None and not _match(match_stdout, stdout):
Expand Down

0 comments on commit 57014c5

Please sign in to comment.