Sending SMS on task failure - Prefect 2.0 - Plivo ...
# prefect-community
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
Hi @YD This discourse shares how you might add a state handler for the task level in 2.0
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
Does it ?
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?
just when failed state and when all retries did not succeeded.
Ok then that should take into account all the retries