Kill subprocess before mutating state in change_workspace()#125
Kill subprocess before mutating state in change_workspace()#125
Conversation
Move await self._kill() above the attribute mutations in change_workspace(). An in-flight _send_locked() reads self.workspace, self.timeout_seconds, and self.workspace_config at multiple await points during streaming. Mutating before killing lets the stream see new config values while still running the old workspace process. Killing first ensures the stream hits EOF and exits before any state changes take effect. Fixes #121
Review by KaiPR Review: Kill subprocess before mutating state in
|
Summary
await self._kill()above attribute mutations inchange_workspace()to fix a race condition_send_locked()readsself.workspace,self.timeout_seconds, andself.workspace_configat multipleawaitpoints during streamingThe attribute mutation block itself is unchanged. This is purely a reordering of
_kill()relative to the mutations.The race
Test plan
_killwith a side-effect that recordsself.workspaceat call time, asserts it sees the original workspace (not the new one)TestChangeWorkspaceandTestWorkspaceConfigtests verify final attribute values, which are unchanged)make lintcleanawait self._kill()appears before anyself.workspace =orself.model =assignmentsFixes #121