def control(self, action, args, kwargs): # we convert the action into a mixedCase method name action_method = getattr(self, "action" + action.capitalize(), None) if action_method is None: raise exceptions.InvalidControlException( "action: {} is not supported".format(action)) return action_method(args, kwargs)
def control(self, action, args, kwargs): if action not in ("stop", "pause", "unpause", "kill"): raise exceptions.InvalidControlException("action: {} is not supported".format(action)) worker = yield self.get(None, kwargs) if worker is not None: self.master.mq.produce(("control", "worker", str(worker['workerid']), action), dict(reason=kwargs.get('reason', args.get('reason', 'no reason')))) else: raise exceptions.exceptions.InvalidPathError("worker not found")