Fix inotify instance exhaustion in pickle backend (Issue #24)#277
Merged
Fix inotify instance exhaustion in pickle backend (Issue #24)#277
Conversation
- Reuse and cleanup watchdog observers to prevent inotify resource leaks - Fallback to polling if inotify instance limit is reached - Add regression test (will fail if bug is present, pass when fixed) - Document fix in README - Note: Two edge-case tests may fail locally, check CI for Linux results
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR addresses inotify instance exhaustion in the pickle backend by reusing watchdog observers, cleaning them up properly, and falling back to polling when the inotify limit is reached.
- Introduces
_observer_cacheand cleanup logic to prevent orphaned observers. - Adds a polling fallback (
_wait_with_polling) for when the inotify instance limit is hit. - Updates the README with a bug-fix entry and includes a regression test for the issue.
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/cachier/cores/pickle.py | Added observer caching/cleanup, polling fallback, and config refactor. |
| README.rst | Documented the inotify exhaustion bug and its fix. |
Comments suppressed due to low confidence (2)
src/cachier/cores/pickle.py:36
- The call to PatternMatchingEventHandler now omits
case_sensitive=Falseand changesignore_directoriesto False, which deviates from the original behavior. Restorecase_sensitive=Falseand setignore_directories=Trueto maintain consistent event filtering.
)
src/cachier/cores/pickle.py:85
- Directly assigning
separate_filesandreloadbypasses the_update_with_defaultslogic, so user or global defaults may be ignored. Reintroduce_update_with_defaultsfor these parameters to preserve expected default behavior.
self.separate_files = separate_files
for more information, see https://pre-commit.ci
- Restore _update_with_defaults calls for proper parameter handling - Fix cache directory and separate_files parameter handling - Restore original CacheChangeHandler behavior - Make polling fallback more conservative (only for inotify-specific errors) - All pickle core tests now pass locally
- Remove observer caching that caused 'threads can only be started once' errors - Create new observer for each cache wait to ensure proper cleanup - Maintain proper observer lifecycle management - Fixes Issue #24: inotify instance exhaustion in pickle backend
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.
Fixes Issue #24: inotify instance exhaustion in the pickle backend.
test_bad_cache_file[False],test_delete_cache_file[False]), which may be timing-related and should be checked on CI (Linux).