Commit cd6d1f92 by James Cammarata

Fix pickling errors with cache plugins (v2)

Fixes #10945
parent 198476e3
......@@ -26,6 +26,9 @@ from six import add_metaclass
@add_metaclass(ABCMeta)
class BaseCacheModule:
def __init__(self):
self.__getstate__ = self.copy
@abstractmethod
def get(self, key):
pass
......@@ -53,3 +56,4 @@ class BaseCacheModule:
@abstractmethod
def copy(self):
pass
......@@ -113,6 +113,8 @@ class CacheModuleKeys(collections.MutableSet):
self._cache = cache
self._keyset = dict(*args, **kwargs)
super(CacheModule, self).__init__()
def __contains__(self, key):
return key in self._keyset
......
......@@ -24,6 +24,8 @@ class CacheModule(BaseCacheModule):
def __init__(self, *args, **kwargs):
self._cache = {}
super(CacheModule, self).__init__()
def get(self, key):
return self._cache.get(key)
......
......@@ -51,6 +51,8 @@ class CacheModule(BaseCacheModule):
self._cache = StrictRedis(*connection)
self._keys_set = 'ansible_cache_keys'
super(CacheModule, self).__init__()
def _make_key(self, key):
return self._prefix + key
......@@ -100,3 +102,4 @@ class CacheModule(BaseCacheModule):
for key in self.keys():
ret[key] = self.get(key)
return ret
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment