Remove PICKLE_PROTOCOL setting and use Python default
🙂 Looking for an issue? Welcome! This issue is open for contribution. If this is the first time you’re requesting an issue, please:
- Read Contributing guidelines carefully. Pay extra attention to Using generative AI. Pull requests and comments that don’t follow the guidelines won’t be answered.
- Confirm that you’ve read the guidelines in your comment.
Overview
The PICKLE_PROTOCOL option exists to pin the pickle protocol used by the cache backends. It defaults to 2 (Python 2's max) and is no longer needed — task data is now serialized as JSON, and the cache is the only consumer. If a cache contains data from an incompatible protocol, it should be caught and treated as a cache miss rather than maintained via a global protocol pin.
Complexity: Medium
Target branch: release-v0.19.x
Context
The setting is defined in kolibri/utils/options.py under the Python section and consumed in kolibri/deployment/default/cache.py where it's passed to:
- The disk-based process cache as
disk_pickle_protocol - The Redis cache as
PICKLE_VERSION
The comments in cache.py (lines 33, 48) say "Pin pickle protocol for Python 2 compatibility" which is outdated.
The Change
- Remove the
PICKLE_PROTOCOLoption from thePythonsection inkolibri/utils/options.py. - Remove the
pickle_protocolvariable and its usage fromkolibri/deployment/default/cache.py— let the cache backends use Python's default protocol. - Add pickle deserialization errors (e.g.,
pickle.UnpicklingError) toERRORS_TO_HANDLEinkolibri/deployment/default/custom_django_cache.py, so stale cache entries pickled with an incompatible protocol are silently treated as cache misses. - Remove the outdated "Python 2 compatibility" comments in
cache.py.
Acceptance Criteria
- [ ] The
PICKLE_PROTOCOLoption is removed fromkolibri/utils/options.py - [ ]
kolibri/deployment/default/cache.pyno longer referencespickle_protocolor contains Python 2 comments - [ ]
CustomDjangoCacheinkolibri/deployment/default/custom_django_cache.pyhandles pickle deserialization errors gracefully - [ ] All existing tests pass
🤖 This issue was written with AI assistance, under supervision, review and final edits by [@rtibbles] 🤖
I want to work on this.
hello @rtibbles if you are assigning this issue to swoyamjeetcode then pls can you assign Convert facility management issue #14195 to me.
I have assigned to @Swoyamjeetcodes - as he asked first. @curiouscoder-cmd, there are other available help wanted issues, please look at those. Our guidelines restrict contributors to two issues at once, so it's not either or.
Will raise a PR soon !
@rtibbles check #14198, this commit