Commit e5aa438f authored by Wout De Nolf's avatar Wout De Nolf
Browse files

Merge branch '9-errors-in-pythonactor-result-handler-is-not-properly-handled' into 'main'

Resolve "Errors in pythonactor result handler is not properly handled"

Closes #9

See merge request !20
parents a01e888c d561a805
Pipeline #61747 passed with stages
in 38 seconds
...@@ -118,7 +118,7 @@ class PythonActor(AbstractActor): ...@@ -118,7 +118,7 @@ class PythonActor(AbstractActor):
self.listErrorHandler.append(errorHandler) self.listErrorHandler.append(errorHandler)
def trigger(self, inData: dict): def trigger(self, inData: dict):
logger.info("In trigger %s, inData = %s", self.name, pprint.pformat(inData)) logger.debug("In trigger %s, inData = %s", self.name, pprint.pformat(inData))
self.setStarted() self.setStarted()
self.inData = dict(inData) self.inData = dict(inData)
self.uploadInDataToMongo(actorData={"inData": inData}, script=self.script) self.uploadInDataToMongo(actorData={"inData": inData}, script=self.script)
...@@ -141,29 +141,38 @@ class PythonActor(AbstractActor): ...@@ -141,29 +141,38 @@ class PythonActor(AbstractActor):
self.af.call(**self.inData) self.af.call(**self.inData)
def resultHandler(self, result: dict): def resultHandler(self, result: dict):
# Handle the result """Async callback in case of success"""
logger.debug("In resultHandler for '%s'", self.name) try:
self._finishedSuccess(result) # Handle the result
logger.debug("In resultHandler for '%s'", self.name)
# Trigger actors self._finishedSuccess(result)
downstreamData = dict(self.inData)
downstreamData.update(result) # Trigger actors
self._triggerDownStreamActors(downstreamData) downstreamData = dict(self.inData)
downstreamData.update(result)
self._triggerDownStreamActors(downstreamData)
except Exception as e:
self.errorHandler(e)
def errorHandler(self, exception: Exception): def errorHandler(self, exception: Exception):
# Handle the result """Async callback in case of exception"""
logger.error( try:
"Error in python actor '%s'! Not running down stream actors %s", # Handle the result
self.name, logger.debug("In errorHandler for '%s'", self.name)
[actor.name for actor in self.listDownStreamActor], logger.error(
) "Error in python actor '%s'! Not running down stream actors %s",
result = self._parseException(exception) self.name,
self._finishedFailure(result) [actor.name for actor in self.listDownStreamActor],
)
# Trigger actors result = self._parseException(exception)
downstreamData = dict(self.inData) self._finishedFailure(result)
downstreamData["WorkflowException"] = result
self._triggerErrorHandlers(downstreamData) # Trigger actors
downstreamData = dict(self.inData)
downstreamData["WorkflowException"] = result
self._triggerErrorHandlers(downstreamData)
except Exception:
logger.exception("In errorHandler for '%s'", self.name)
def _parseException(self, exception: Exception) -> dict: def _parseException(self, exception: Exception) -> dict:
errorMessage = str(exception) errorMessage = str(exception)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment