Skip to content

Commit 03aa31f

Browse files
committed
docs: Note the reader window in Session.state
A second independent review of a299030..83a62a9 was clean (no high or medium items). This commit takes its low items. - The state property's comment now says that a reader paused between its read of _state and its read of _ending_only, while a whole failing action runs on another thread, can report READY_ENDING a moment early while _state is still RUNNING. It never reports READY for a failed action; reading the flag first would bring that back. - For the record, the full list of public calls whose result differs after exit_environment(keep_session_running=False) raises an exception before it stores RUNNING (the Session reads READY_ENDING where it read READY): run_task, enter_environment and run_subprocess are now refused where they were accepted, and clear_ending_only() is now accepted where it was refused. Comment-only change; black and ruff pass, and test_brittle_session.py passes (51). Signed-off-by: Mark Wiebe <399551+mwiebe@users.noreply.github.com>
1 parent fa43ce5 commit 03aa31f

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

‎src/openjd/sessions/_session.py‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -682,7 +682,10 @@ def state(self) -> SessionState:
682682
"""
683683
# Read _state once. Another thread can store READY between two reads,
684684
# and _ending_only is always set before READY is stored for a failed
685-
# action, so a single read never reports READY for one.
685+
# action, so a single read never reports READY for one. The flag is
686+
# read second, so a reader that stays paused between the two reads
687+
# while a whole failing action runs reports READY_ENDING a moment
688+
# early, while _state is still RUNNING; it never reports READY late.
686689
state = self._state
687690
if state == SessionState.READY and self._ending_only:
688691
return SessionState.READY_ENDING

0 commit comments

Comments
 (0)