def executeTask(self, listener, taskname, taskargs): if self.agent == None: self.agent = G._AGENT staskargs = fromXPS(taskargs) log_incoming_request(listener, "executeTask", (listener, taskname, staskargs)) symOrError = taskNameToSymOrError(self.agent, taskname) if isString(symOrError): requestType = FAIL_REQUEST term = symOrError else: mode = optMode(self.agent, symOrError, ACTION_DO) if mode: requestType = "d" inargs = [ _if(usage == TERM_EVAL, x, None) for (x, usage) in zip(staskargs, mode) ] debug("inargs = %r", inargs) term = Structure(symOrError, List(inargs)) else: requestType = FAIL_REQUEST term = "Cannot find argument modes" #debug("initiating task via (%s, %r, %r, %r)", S_ExecuteTask.id, requestType, listener, term) self.agent.add_ephemeral(S_ExecuteTask, requestType, listener, term)
def executingTask(self, parentListener, taskname, taskargs): requestId = log_incoming_request( None, "executingTask", (parentListener, taskname, fromXPS(taskargs))) listener = _SparkExecutionListener(self.agent, parentListener) debug("creating listener %s with parent %s", listener, parentListener) log_outgoing_result(requestId, "result", listener) return listener
def executeTask(self, listener, taskname, taskargs): if self.agent == None: self.agent = G._AGENT staskargs = fromXPS(taskargs) log_incoming_request(listener, "executeTask", (listener, taskname, staskargs)) symOrError = taskNameToSymOrError(self.agent, taskname) if isString(symOrError): requestType = FAIL_REQUEST term = symOrError else: mode = optMode(self.agent, symOrError, ACTION_DO) if mode: requestType = "d" inargs = [_if(usage == TERM_EVAL, x, None) for (x, usage) in zip(staskargs, mode)] debug("inargs = %r", inargs) term = Structure(symOrError, List(inargs)) else: requestType = FAIL_REQUEST term = "Cannot find argument modes" #debug("initiating task via (%s, %r, %r, %r)", S_ExecuteTask.id, requestType, listener, term) self.agent.add_ephemeral(S_ExecuteTask, requestType, listener, term)
def taskSucceeded(self, boundParameters): result = fromXPS(boundParameters) log_incoming_result(self, "success", result) self.agent.add_ephemeral(S_taskSucceeded, self, result)
def executingTask(self, parentListener, taskname, taskargs): requestId = log_incoming_request(None, "executingTask", (parentListener, taskname, fromXPS(taskargs))) listener = _SparkExecutionListener(self.agent, parentListener) debug("creating listener %s with parent %s", listener, parentListener) log_outgoing_result(requestId, "result", listener) return listener