-
Notifications
You must be signed in to change notification settings - Fork 4k
Make file watcher more error-resistant #11841
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
🎉 Snyk checks have passed. No issues have been found so far.✅ security/snyk check is complete. No issues have been found. (View Details) ✅ license/snyk check is complete. No issues have been found. (View Details) |
✅ PR preview is ready!
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR enhances the file-watching logic by normalizing paths with os.path.realpath, improving error handling in watcher registration and path-change events, and updating tests to accommodate full path comparisons.
- Switched from
os.path.abspathtoos.path.realpathacross watcher implementations for consistent path normalization. - Wrapped watcher scheduling and MD5 computation in broader exception handling with logged warnings.
- Adjusted tests to match substrings in full paths rather than exact filenames.
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| lib/tests/streamlit/watcher/local_sources_watcher_test.py | Updated assertions to use substring checks for full paths. |
| lib/streamlit/watcher/util.py | Added a blank line before retry loop in _do_with_retries. |
| lib/streamlit/watcher/local_sources_watcher.py | Replaced abspath with realpath and improved exception logging. |
| lib/streamlit/watcher/event_based_path_watcher.py | Switched to realpath, ignored editor backup files, and added exception handling in scheduling and MD5 calc. |
Comments suppressed due to low confidence (1)
📉 Python coverage change detectedThe Python unit test coverage has decreased by 0.0508%
💡 Consider adding more unit tests to maintain or improve coverage. Coverage by files
|
sfc-gh-lwilby
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
## Describe your changes Follow-up to #11841 to improve the exception handling. The changes in #11841 can create some confusing logs and catch unrelated exceptions (e.g. runtime errors when the runtime shuts down). ## Testing Plan - This is mainly about logging and doesn't have any functional impact. --- **Contribution License Agreement** By submitting this pull request you agree that all contributions to this project are made under the Apache 2.0 license.
Describe your changes
Applies a couple of improvements to the file watcher to make it more error-resistant.
GitHub Issue Link (if applicable)
File changed in watched directorylog while the file has not changed #11809Testing Plan
Contribution License Agreement
By submitting this pull request you agree that all contributions to this project are made under the Apache 2.0 license.