Skip to content

Commit f19bf23

Browse files
committed
fix: poll through CANCELING state to deliver terminal callback
The _poll_for_completion thread exited the polling loop as soon as the session state transitioned away from RUNNING. When cancel_action() is called, the pyo3 binding immediately sets the snapshot state to CANCELING — causing the poller to exit before the subprocess has been killed and before the Rust callback delivers the terminal CANCELED ActionStatus. The result: the worker agent never receives the CANCELED callback, leaving the action stuck in CANCELING forever from the service's perspective. Fix: treat CANCELING as an in-progress state (like RUNNING) and continue polling. The poller now exits only when the state reaches READY or READY_ENDING, at which point action_status contains the correct terminal state. Signed-off-by: Sean Tang <seant-aws@users.noreply.github.com> Signed-off-by: Sean Tang <171081544+seant-aws@users.noreply.github.com>
1 parent 36e85fb commit f19bf23

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

src/openjd/sessions/_v1/_session.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ def observable(s: ActionStatus) -> tuple:
186186
while True:
187187
state = self._rust_session.state
188188
status = self._rust_session.action_status
189-
if state == SessionState.RUNNING:
189+
if state in (SessionState.RUNNING, SessionState.CANCELING):
190190
if status is not None and self._callback:
191191
if not reported_running:
192192
# Defensive: the synchronous initial callback
@@ -201,7 +201,7 @@ def observable(s: ActionStatus) -> tuple:
201201
self._callback(self._session_id, status)
202202
time.sleep(0.05)
203203
continue
204-
# Not RUNNING anymore — action is done.
204+
# Not RUNNING/CANCELING anymore — action is done.
205205
# If we never saw RUNNING (e.g. Rust finished before we got here),
206206
# still report the RUNNING transition first, so the agent state
207207
# machine sees Start → End in order.

0 commit comments

Comments
 (0)