Esempio n. 1
0
 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()
Esempio n. 2
0
 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()
Esempio n. 3
0
File: core.py Progetto: lcrees/shove
 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
Esempio n. 4
0
 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
Esempio n. 5
0
File: conf.py Progetto: lcrees/stage
 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)
Esempio n. 6
0
 def _cull(self):
     # cull remainder of allowed quota at random
     xpartmap(
         delitem, sample(list(self), len(self) - self._max_entries), self
     )
Esempio n. 7
0
 def _cull(self):
     # cull remainder of allowed quota at random
     xpartmap(delitem, sample(list(self),
                              len(self) - self._max_entries), self)
Esempio n. 8
0
File: core.py Progetto: lcrees/shove
 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()