Repository navigation
Fix watch subscription timeout handling - #584
ShivaniSharma14 wants to merge 2 commits into
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: dcef2ea40e
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| pending.cancel() | ||
|
|
||
| try: | ||
| await pending |
There was a problem hiding this comment.
Always close the iterator after pending-read errors
When the consumer stops after a timeout and the outstanding __anext__ completes with an ordinary exception before aclose() runs, await pending re-raises that exception because the handler only catches cancellation/end-of-iteration, so execution skips the final iterator.aclose() entirely. This regresses the helper's guaranteed-cleanup contract for iterators whose failed read does not close themselves; place aclose() in a nested finally while still allowing the read exception to propagate.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Thanks for pointing this out! I've updated the cleanup logic to ensure iterator.aclose() runs in a nested finally block even if awaiting the pending read raises an exception. I've also added a regression test for this case, and all focused tests pass.
##SummaryFixes #509, where
docket watchmay exit with code0while the task is still running.Problem
The timeout handling in
iterate_with_timeout()usedasyncio.wait_for()to await the next item from the subscription iterator. When the timeout expired,wait_for()cancelled the pending read. This could terminate the async subscription iterator, causing the watch command to stop waiting before the task reached a terminal state.Changes
Nonewhen a timeout occurs, allowing the caller to continue its polling behavior.Testing
python -m pytest -q -n0 --no-cov --confcutdir=python/tests/cli python/tests/cli/test_iterate_with_timeout.py— 7 passed.The broader CLI test run encountered fixture setup errors, so the full CLI suite has not been verified successfully.
Closes #509