fix(code-kernel): evict the remote kernel when a cell request fails to ship
The cell ship now fails closed (RuntimeError). _execute_remote catches it and falls back to per-call execution, but the kernel stayed registered with cell_seq bumped. The next call would then reuse a kernel whose state silently missed this cell, with no state_lost flag. Discard (kill) it the way the timeout path does, so the next call starts a fresh kernel. The request never reached the runner (atomic publish), so the fallback still runs the code exactly once.
This commit is contained in:
@@ -380,6 +380,13 @@ def _run_attached_cell(kernel: RemoteKernel, key: Tuple, code: str, *, env, task
|
||||
cell_status, cell_payload = "no-result", {}
|
||||
try:
|
||||
cell_status, cell_payload = _run_remote_cell(kernel, code, timeout)
|
||||
except Exception:
|
||||
# The request never reached the runner (the atomic ship failed), so the
|
||||
# caller's per-call fallback runs the code exactly once. Kill the
|
||||
# kernel as the timeout path does: leaving it registered would let the
|
||||
# next call reuse a kernel whose state silently missed this cell.
|
||||
_REGISTRY.discard(key, kernel)
|
||||
raise
|
||||
finally:
|
||||
stop_event.set()
|
||||
rpc_thread.join(timeout=5)
|
||||
|
||||
Reference in New Issue
Block a user