if response and self.consume: if isinstance(response, GeneratorType): pdwtLog.debug("Generator", response) for r in response: pdwtLog.debug("Yielded", r) self.consume(r) pdwtLog.debug("End of generator", response) else: pdwtLog.debug("Returning", response) self.consume(response) else: pdwtLog.debug("Not returning.", response) except NameError,n: pdwtLog.exception("NameError while evaluating plugin!", n.message) except: pdwtLog.exception("Exception while evaluating plugin!") def Stop(self): pdwtLog.debug("Set stop flag") self.running = False class PluginDispatcher: __queue__ = [] __workerThreads__ = [] __dedicatedThreads__ = {} __lock__ = threading.Condition() ResponseHandler = None def __init__(self): pdLog.debug("Creating worker threads.")
if cf: log.debug("Autoloading plugins.") names = cf["Plugins", "Names"] log.debug("Autoloading plugins", names) if names: for name in names.split(): pm.LoadPlugin(name) log.debug("Autoloading finished.") pd=self._PluginDispatcher handler = pd.GetResponseHandler() log.debug("Updating dedicated thread pool",self._ResponseObject,handler) pd.EnsureDedicated(pm.GetDedicated(),self._ResponseObject,handler) else: log.note("No Autoload configuration file") if __name__ == "__main__": try: c = Core() try: c.Start() except: log.exception("Exception while starting.") c.Stop() except: log.exception("Exception while stopping.") log.debug("End of core")