Sending SMS on task failure - Prefect 2.0 - Plivo ...
# prefect-community
y
Sending SMS on task failure - Prefect 2.0 - Plivo I use Plivo as SMS service, not Twilio in Prefect 1.0 I used
'state_handlers': [o.p_state_handler]
which sent me an SMS alert on task failure. how can i achieve this kind of behavior in Prefect 2.0? thanks
k
Hi @YD This discourse shares how you might add a state handler for the task level in 2.0 https://discourse.prefect.io/t/how-to-take-action-on-a-state-change-of-a-task-run-task-level-state-handler/82/10
y
thanks, trying it…
What does the
task_future.wait()  # block until completion
blocking? my current handler also looks check the max retries.
prefect.context.get("task_run_count") > obj.max_retries
and I check that task is finished and failed
new_state.is_finished() and new_state.is_failed()
In Prefect 2.0 I can do:
r = task_future.get_state()
and then check
if r.is_final() and r.is_failed()
but I do not see if this take into account the
retries
Does it ?
k
retries are not considered a finished or failed state. Do you want the state hander to trigger when it goes into a retrying state or just that finished or failed state?
y
just when failed state and when all retries did not succeeded.
k
Ok then that should take into account all the retries