Skip to content

Commit 618f3c3

Browse files
committed
Handle cancelled persisted results as terminal failures.
Treat cancelled result states as immediate runtime errors and add coverage so result polling no longer times out on terminal cancellation.
1 parent 6068b56 commit 618f3c3

2 files changed

Lines changed: 15 additions & 2 deletions

File tree

hotdata_runtime/client.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
from hotdata_runtime.result import QueryResult
2626

2727
_TERMINAL = frozenset({"succeeded", "failed", "cancelled"})
28+
_RESULT_FAILURE = frozenset({"failed", "cancelled"})
2829

2930

3031
class HotdataClient:
@@ -206,9 +207,9 @@ def _wait_result_ready(
206207
last = results.get_result(result_id)
207208
if last.status == "ready":
208209
return last
209-
if last.status == "failed":
210+
if last.status in _RESULT_FAILURE:
210211
raise RuntimeError(
211-
last.error_message or "Result persistence failed"
212+
last.error_message or f"Result {last.status}"
212213
)
213214
time.sleep(interval_s)
214215
raise TimeoutError(

tests/test_client.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,3 +109,15 @@ def test_list_qualified_table_names_passes_connection_id():
109109
client.list_qualified_table_names(limit=5, connection_id="conn_a")
110110
it.assert_called_once()
111111
assert it.call_args.kwargs["connection_id"] == "conn_a"
112+
113+
114+
def test_wait_result_ready_raises_on_cancelled():
115+
client = HotdataClient("k", "ws", host="https://api.hotdata.dev")
116+
117+
class FakeResultsApi:
118+
def get_result(self, result_id: str):
119+
return SimpleNamespace(status="cancelled", error_message=None)
120+
121+
with patch.object(client, "_results_api", return_value=FakeResultsApi()):
122+
with pytest.raises(RuntimeError, match="cancelled"):
123+
client._wait_result_ready("res_1", timeout_s=0.1, interval_s=0)

0 commit comments

Comments
 (0)