def sync(self): '''Writes buffer to store.''' with ThreadPoolExecutor(max_workers=self._maxworkers) as executor: xpartmap( executor.submit, self._stores, methodcaller('update', self._buffer), ) self._buffer.clear()
def __delitem__(self, key): try: self.sync() except AttributeError: pass with ThreadPoolExecutor(max_workers=self._maxworkers) as executor: xpartmap(executor.submit, self._stores, methodcaller("__delitem__", key)) try: del self._cache[key] except KeyError: pass
def __delitem__(self, key): try: self.sync() except AttributeError: pass with ThreadPoolExecutor(max_workers=self._maxworkers) as executor: xpartmap( executor.submit, self._stores, methodcaller('__delitem__', key), ) try: del self._cache[key] except KeyError: pass
def _load(self, destination, conf): # load configuration if isstring(conf): # load import conf = lazyimport(conf) if isinstance(conf, _BaseFactory): # load configuration from factory destination.update(i for i in conf) elif isclass(conf): # load configuration from class newconf = {} xpartmap( lambda x, y: x({y.pop('classname', 'options'): y}), iter(lazyknife(conf).traverse().attrs('maps').merge()), newconf.update, ) destination.update(newconf)
def _cull(self): # cull remainder of allowed quota at random xpartmap( delitem, sample(list(self), len(self) - self._max_entries), self )
def _cull(self): # cull remainder of allowed quota at random xpartmap(delitem, sample(list(self), len(self) - self._max_entries), self)
def sync(self): """Writes buffer to store.""" with ThreadPoolExecutor(max_workers=self._maxworkers) as executor: xpartmap(executor.submit, self._stores, methodcaller("update", self._buffer)) self._buffer.clear()