Danny Vilela03/25/2022, 7:29 PM
) is it possible to recover that traceback/error from a state handler? Right now I can say “this task failed and will be retrying in X minutes”, but not “this task failed for reason Y and will retry in X minutes”. Or can we pass keyword arguments to a state handler with this signature:
# What I have now. def notify_on_retry(task: Task, old_state: State, new_state: Retrying) -> State: ... # Maybe what I want? def notify_on_retry(task: Task, old_state: State, new_state: Retrying, message: str) -> State: ... # Alternative? def notify_on_retry(task: Task, old_state: State, new_state: Retrying, **kwargs) -> State: ...
Danny Vilela03/25/2022, 7:32 PM
would be the
from prefect import Flow, task import prefect def handler(obj, old_state, new_state): if new_state.is_failed(): <http://prefect.context.logger.info|prefect.context.logger.info>(new_state.result) return new_state @task(state_handlers=[handler]) def abc(): raise ValueError("MESSAGE HERE") with Flow(",,") as flow: abc() flow.run()
also. and you can pull the exception message with