summaryrefslogtreecommitdiff
path: root/requests_cache
diff options
context:
space:
mode:
authorJordan Cook <jordan.cook.git@proton.me>2022-10-20 13:03:45 -0500
committerJordan Cook <jordan.cook.git@proton.me>2022-10-20 13:09:55 -0500
commit54d85c12bf4aa98e2798f18b7c4719b1ba493770 (patch)
treed9dd9003a4297c268cff7096e4aaf7a81cba5254 /requests_cache
parent2cfccd966876349ffbfd5a44a6db684966468b95 (diff)
downloadrequests-cache-54d85c12bf4aa98e2798f18b7c4719b1ba493770.tar.gz
Explicitly disable pickling CachedSession objects
Diffstat (limited to 'requests_cache')
-rw-r--r--requests_cache/session.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/requests_cache/session.py b/requests_cache/session.py
index e58cc57..3dbdb05 100644
--- a/requests_cache/session.py
+++ b/requests_cache/session.py
@@ -311,6 +311,12 @@ class CacheMixin(MIXIN_BASE):
"""**Deprecated:** Use ``session.cache.remove(expired=True)`` instead"""
self.cache.delete(expired=True, invalid=True)
+ def __getstate__(self):
+ # Unlike requests.Session, CachedSession may contain backend connection objects that can't
+ # be pickled. Support for this could be added if necessary, but for now it's explicitly
+ # disabled to avoid confusing errors upon unpickling.
+ raise NotImplementedError('CachedSession cannot be pickled')
+
def __repr__(self):
return f'<CachedSession(cache={repr(self.cache)}, settings={self.settings})>'