fix(scheduler): handle delivery timeout and fix BaseException catch#3563
Open
Kewe63 wants to merge 2 commits intoNousResearch:mainfrom
Open
fix(scheduler): handle delivery timeout and fix BaseException catch#3563Kewe63 wants to merge 2 commits intoNousResearch:mainfrom
Kewe63 wants to merge 2 commits intoNousResearch:mainfrom
Conversation
- Fix incorrect type annotations: last_prompt_tokens and model parameters in update_session() were annotated as int/str with None defaults; corrected to Optional[int] and Optional[str] - Add OSError handling in append_to_transcript() JSONL write path; previously an unhandled IOError would propagate and break the caller's flow - Make rewrite_transcript() JSONL write atomic using tempfile + os.fsync + os.replace to prevent data loss if the write fails mid-way (file was previously truncated before new content landed)
- Wrap ThreadPoolExecutor fallback in try/except to catch concurrent.futures.TimeoutError (30s timeout) which previously propagated unhandled and crashed the delivery path - Replace invalid `except (Exception, KeyboardInterrupt)` with `except BaseException` in session cleanup finally block; KeyboardInterrupt derives from BaseException not Exception, so the previous clause never caught it
Contributor
Author
|
BaseException is used intentionally here in a finally cleanup block catching KeyboardInterrupt ensures the SQLite session is properly closed even on Ctrl+C, preventing potential data corruption. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🐛 Bug Fixes
cron/scheduler.pyThreadPoolExecutorfallback in_deliver_result()had no timeout error handling — a 30sexcept concurrent.futures.TimeoutErrorcron/scheduler.pyexcept (Exception, KeyboardInterrupt)is redundant —KeyboardInterruptderives fromBaseExceptionnotException, so it was never caught; replaced withexcept BaseException🧪 Test Results
📋 Change Summary
cron/scheduler.py)✅ Checklist