Merge pull request #124972 from andir/nixos-test-driver-timeout-error

nixos/test-driver: mention the elapsed time when it times out
master
Andreas Rammhold 2021-05-30 18:30:12 +02:00 committed by GitHub
commit fcbfb5037b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 3 deletions

View File

@ -128,18 +128,18 @@ def create_vlan(vlan_nr: str) -> Tuple[str, str, "subprocess.Popen[bytes]", Any]
return (vlan_nr, vde_socket, vde_process, fd)
def retry(fn: Callable) -> None:
def retry(fn: Callable, timeout: int = 900) -> None:
"""Call the given function repeatedly, with 1 second intervals,
until it returns True or a timeout is reached.
"""
for _ in range(900):
for _ in range(timeout):
if fn(False):
return
time.sleep(1)
if not fn(True):
raise Exception("action timed out")
raise Exception(f"action timed out after {timeout} seconds")
class Logger: