Hi everyone, I am trying to send slack notificatio...
# ask-community
v
Hi everyone, I am trying to send slack notifications for each and every task if it is a succeeds or fails. do i have to specify the state_handler for each task as or specify it once in the
Copy code
with Flow(state_handler=[post_to_Slack]):
or
Copy code
@task(log_stdout=True, max_retries=3, retry_delay=datetime.timedelta(minutes=5),state_handler=[post_to_slack])
def some_task():
   return something
k
The state handler attached to the Flow is for Flow state changes while the one attached to the task is for task state changes. So you want the task level one.
v
so i can use this ?
Copy code
@task(log_stdout=True, max_retries=3, retry_delay=datetime.timedelta(minutes=5),state_handler=[post_to_slack])
k
Yes but I think it might be
state_handlers
👍 1
v
Thank you!!
is it possible to have a task that will only run if a flow fails?
k
If you want a python script that is not a task, put it in the flow state handler. If you want a task that runs if another task fails, use an
all_failed
trigger.