mirror of
https://github.com/OPM/ResInsight.git
synced 2026-10-24 22:27:55 -05:00
#14683 Python: Preserve positional heartbeat callback
This commit is contained in:
1 parent
35614d160e
commit
2e5a3a3d17
2 files changed
+15
-4
No files matched your search
@@ -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")
|
||||
|
||||
@@ -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!'."""
|
||||
|
||||
Reference in new issue
Block a user