Describe the bug
An error occurs when attempting to cache objects using Flask-Caching with cachelib in a Flask application. The error is a TypeError indicating that 'BufferedReader' instances cannot be pickled.
To Reproduce
Steps to reproduce the behavior:
Use Flask-Caching with cachelib as the caching backend in a Flask application.
Attempt to cache an object that includes or is a BufferedReader instance.
Trigger the caching mechanism (e.g., by accessing a route that performs caching).
See the error: TypeError: cannot pickle 'BufferedReader' instances
Expected behavior
Objects, including those containing or being BufferedReader instances, should be serialized and cached without raising a TypeError. Alternatively, a more informative error or a mechanism to handle non-serializable objects gracefully should be provided.
Screenshots
N/A
Desktop:
All clients
Additional context
This issue may arise from the serialization process used by cachelib when caching objects. pickle.dumps() is used for serialization, which does not support BufferedReader instances. A potential workaround involves manually handling serialization for these instances or avoiding caching them directly.
Describe the bug An error occurs when attempting to cache objects using Flask-Caching with cachelib in a Flask application. The error is a
TypeError
indicating that 'BufferedReader' instances cannot be pickled.To Reproduce Steps to reproduce the behavior:
BufferedReader
instance.TypeError: cannot pickle 'BufferedReader' instances
Expected behavior Objects, including those containing or being
BufferedReader
instances, should be serialized and cached without raising aTypeError
. Alternatively, a more informative error or a mechanism to handle non-serializable objects gracefully should be provided.Screenshots N/A
Desktop:
Additional context This issue may arise from the serialization process used by
cachelib
when caching objects.pickle.dumps()
is used for serialization, which does not supportBufferedReader
instances. A potential workaround involves manually handling serialization for these instances or avoiding caching them directly.