From 0f3f11931f69146123bb3f0878da6925aeb4b9a7 Mon Sep 17 00:00:00 2001 From: Josh Roesslein Date: Thu, 30 Jul 2009 14:03:09 -0500 Subject: [PATCH] Make MemoryCache picklable. --- tweepy/cache.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tweepy/cache.py b/tweepy/cache.py index 1e1b37e..9062f22 100644 --- a/tweepy/cache.py +++ b/tweepy/cache.py @@ -44,6 +44,16 @@ class MemoryCache(Cache): self._entries = {} self.lock = threading.Lock() + def __getstate__(self): + # pickle + return {'entries': self._entries, 'timeout': self.timeout} + + def __setstate__(self, state): + # unpickle + self.lock = threading.Lock() + self._entries = state['entries'] + self.timeout = state['timeout'] + def _is_expired(self, entry, timeout): return timeout > 0 and (time.time() - entry[0]) >= timeout -- 2.25.1