def run(self, server): locked = False try: self.lock.acquire() locked = True md = self.server.md.clone() for p in server.plumbings: state = {'update': True, 'stats': {}} p.process(md, state) stats.update(state.get('stats', {})) with server.lock.writelock: log.debug("update produced new repository with %d entities" % server.md.store.size()) server.md = md server.md.fire(type=EVENT_REPOSITORY_LIVE, size=server.md.store.size()) stats['Repository Update Time'] = datetime.now() stats['Repository Size'] = server.md.store.size() self.nruns += 1 stats['Updates Since Server Start'] = self.nruns if hasattr(self.server.md.store, 'periodic'): self.server.md.store.periodic(stats) except Exception as ex: log.error(ex.message) finally: if locked: self.lock.release()
def run(self, server): locked = False try: self.lock.acquire() locked = True md = self.server.md.clone() for p in server.plumbings: state = {'update': True, 'stats': {}} p.process(md, state) stats.update(state.get('stats', {})) with server.lock.writelock: log.debug("update produced new repository with %d entities" % server.md.store.size()) server.md = md server.md.fire(type=EVENT_REPOSITORY_LIVE, size=server.md.store.size()) stats['Repository Update Time'] = datetime.now() stats['Repository Size'] = server.md.store.size() self.nruns += 1 stats['Updates Since Server Start'] = self.nruns if hasattr(self.server.md.store, 'periodic'): self.server.md.store.periodic(stats) except Exception, ex: log.error(ex.message)
def run(self, server): locked = False try: if self.lock.acquire(blocking=0): locked = True md = self.server.new_repository() for o in self.server.observers: md.subscribe(o) for p in server.plumbings: state = {'update': True, 'stats': {}} p.process(md, state) stats.update(state.get('stats', {})) if not md.sane(): log.error("update produced insane active repository - will try again later...") with server.lock.writelock: log.debug("update produced new repository with %d entities" % md.index.size()) server.md = md md.fire(type=EVENT_REPOSITORY_LIVE, size=md.index.size()) stats['Repository Update Time'] = datetime.now() stats['Repository Size'] = md.index.size() else: log.error("another instance is running - will try again later...") except Exception, ex: traceback.print_exc(ex)