def close(self, flush=False): with self._global_lock: if self._dbm_shutdown.is_set(): return else: self._dbm_shutdown.set() if hasattr(atexit, 'unregister'): atexit.unregister(self.close) else: try: atexit._exithandlers.remove((self.close, (), {})) except ValueError: pass if self.schema: # release all the failed sources waiting for restart self._event_queue.put(('localhost', (ShutdownException(), ))) # release all the sources for target, source in self.sources.cache.items(): source.close(flush) # close the database self.schema.commit() self.schema.close() # shutdown the _dbm_thread self._event_queue.put(('localhost', (DBMExitException(), ))) self._dbm_thread.join()
def close(self): with self._global_lock: if self._dbm_shutdown.is_set(): return else: self._dbm_shutdown.set() if hasattr(atexit, 'unregister'): atexit.unregister(self.close) else: try: atexit._exithandlers.remove((self.close, (), {})) except ValueError: pass # shutdown the _dbm_thread self._event_queue.shutdown() self._event_queue.bypass((cmsg(None, ShutdownException()), )) self._dbm_thread.join()
def put(self, *argv, **kwarg): raise ShutdownException('shutdown in progress')