Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def __init__(self, upstream, history=None, key=identity, **kwargs):
self.seen = dict()
self.key = key
if history:
from zict import LRU
self.seen = LRU(history, self.seen)
Stream.__init__(self, upstream, **kwargs)
def setup(self, worker):
self.cache = Buffer(
fast={},
slow=Func(
dump=blosc.pack_array,
load=blosc.unpack_array,
d=Buffer(
fast={},
slow=LRU(
n=self._maxdisk,
d=File(os.path.join(worker.local_directory, 'cache')),
weight=lambda k, v: len(v),
),
n=self._maxcompressed,
weight=lambda k, v: len(v),
),
),
n=self._maxmem,
weight=lambda k, v: v.nbytes,
)
self.lock = Lock()
self.hits = 0
self.misses = 0
def __init__(self, child, history=None, key=identity):
self.seen = dict()
self.key = key
if history:
from zict import LRU
self.seen = LRU(history, self.seen)
Stream.__init__(self, child)