def resume(self): """ Resume a graph that has been suspended. """ self_starters = [] for runner in self.runners: for port in runner.component.inports: if port.is_connected() and not port.is_initialized() and \ port._connection._queue: logger.info("Existing data in connection buffer: {}", args=[port]) if runner.status in (StatusValues.TERMINATED, StatusValues.ERROR): runner.kill() continue elif runner.self_starting or \ runner.status in (StatusValues.SUSP_RECV, StatusValues.SUSP_SEND, StatusValues.DORMANT, StatusValues.ACTIVE): self_starters.append(runner) if not self_starters: raise FlowError("No self-starters found") for runner in self_starters: runner.activate()
def go(self, resume=False): """ Execute the network """ import gevent now = time.time() self.active = True deadlock_thread = None try: if resume: self.resume() else: self.initiate() if self.deadlock_test_interval: deadlock_thread = gevent.spawn(self._test_deadlocks) self.wait_for_all() except FlowError as e: s = "Flow Error :" + str(e) logger.info("Network: " + s) raise finally: self.active = False if deadlock_thread: deadlock_thread.kill() duration = time.time() - now logger.info("Run complete. Time: %.02f seconds" % duration) logger.info("Counts:") logger.info(" creates: %d", self.creates) logger.info(" drops (manual): %d", self.drops) logger.info(" drops (old): %d", self.drop_olds) logger.info(" sends: %d", self.sends) logger.info(" receives: %d", self.receives) if self.error is not None: logger.error("re-rasing error") # throw the exception which caused the network to stop raise_with_traceback(self.error)
def go(self, resume=False): """ Execute the network """ import gevent now = time.time() self.active = True deadlock_thread = None self.remove_listeners() for comp in self.graph._components.values(): for inport in comp.inports: if getattr(inport, '_connection', False): if isinstance(inport._connection, Connection): inport._connection.send.event.add_listener( self.send_data) self.connection_listeners.append(inport._connection) elif getattr(inport, '_connections', False): for connection in inport._connections: if isinstance(connection, Connection): connection.send.event.add_listener(self.send_data) self.connection_listeners.append(connection) try: if resume: self.resume() else: self.initiate() if self.deadlock_test_interval: deadlock_thread = gevent.spawn(self._test_deadlocks) self.wait_for_all() except FlowError as e: s = "Flow Error :" + str(e) logger.info("Network: " + s) raise finally: self.active = False if deadlock_thread: deadlock_thread.kill() self.remove_listeners() duration = time.time() - now logger.info("Run complete. Time: %.02f seconds" % duration) logger.info("Counts:") logger.info(" creates: %d", self.creates) logger.info(" drops (manual): %d", self.drops) logger.info(" drops (old): %d", self.drop_olds) logger.info(" sends: %d", self.sends) logger.info(" receives: %d", self.receives) if self.error is not None: logger.error("re-rasing error") # throw the exception which caused the network to stop raise_with_traceback(self.error)