diff --git a/GrpcInterface/Python/rips/instance.py b/GrpcInterface/Python/rips/instance.py index 5bbbe7400d..939ff7ad88 100644 --- a/GrpcInterface/Python/rips/instance.py +++ b/GrpcInterface/Python/rips/instance.py @@ -418,8 +418,8 @@ class Instance: interval_sec: float = 5.0, deadline_sec: float = 5.0, failure_threshold: int = 3, - busy_warning_sec: float = 60.0, on_failure: Optional[Callable[["RipsError"], None]] = None, + busy_warning_sec: float = 60.0, ) -> None: """Start a background thread that periodically pings ResInsight. @@ -452,12 +452,12 @@ class Instance: failure_threshold: Number of consecutive *connection* failures required before the connection is declared lost. Must be >= 1. - busy_warning_sec: Log a warning when the server has been unable - to answer pings for this many seconds in a row. The pending - call is still allowed to run to completion. on_failure: Optional callback invoked once when the heartbeat detects a lost connection. Receives a :class:`RipsError`. + busy_warning_sec: Log a warning when the server has been unable + to answer pings for this many seconds in a row. The pending + call is still allowed to run to completion. """ if failure_threshold < 1: raise RipsError("failure_threshold must be >= 1") diff --git a/GrpcInterface/Python/rips/tests/test_error_reporting.py b/GrpcInterface/Python/rips/tests/test_error_reporting.py index 629cb760a6..0dcf12440e 100644 --- a/GrpcInterface/Python/rips/tests/test_error_reporting.py +++ b/GrpcInterface/Python/rips/tests/test_error_reporting.py @@ -160,6 +160,17 @@ def test_heartbeat_detects_dead_server(): instance.check_alive() +def test_heartbeat_preserves_positional_on_failure_argument(): + instance = _FakeInstance(grpc.StatusCode.UNAVAILABLE) + failures = [] + + instance.start_heartbeat(0.02, 0.02, 1, failures.append) + instance._heartbeat_thread.join(timeout=0.5) + instance.stop_heartbeat() + + assert len(failures) == 1 + + def test_heartbeat_reports_exited_process_with_diagnostic(): """When the launched process has exited, say so explicitly instead of surfacing a bare 'Channel closed!'."""