def run(section, worker_cls): import xodb from xodb.tools.signals import register_signals register_signals() name = os.environ.get('SUPERVISOR_PROCESS_NAME', 'tester') from ConfigParser import ConfigParser if len(sys.argv) < 1: print "usage: %s config_file" % sys.argv[0] sys.exit(-1) config = ConfigParser() config.read(sys.argv[1]) worker_url = config.get(section, 'worker_url') log_file = config.get(section, 'log_file') db_path = config.get(section, 'db_path') logging.basicConfig(filename=log_file % name, level=logging.DEBUG) db = xodb.open(db_path, writable=False) w = worker_cls(name, worker_url, db) logging.debug('Running worker on %s' % worker_url) w.run()
def close(self): self.context.term() def __getattr__(self, name): return Method(name, self) class PromiseClient(Client): def __getattr__(self, name): return Promise(name, self) if __name__ == "__main__": from xodb.tools.signals import register_signals register_signals() import sys from ConfigParser import ConfigParser if len(sys.argv) < 1: print "usage: %s config_file" % sys.argv[0] sys.exit(-1) config = ConfigParser() config.read(sys.argv[1]) client_config = dict(config.items('client')) client_url = client_config.get('client_url') log_file = client_config.get('log_file')