mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-01-18 19:03:28 +00:00
Merge pull request #124972 from andir/nixos-test-driver-timeout-error
nixos/test-driver: mention the elapsed time when it times out
This commit is contained in:
commit
fcbfb5037b
@ -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:
|
||||
|
Loading…
Reference in New Issue
Block a user