Hi everyone! I'm setting some state handlers for n...
# prefect-community
f
Hi everyone! I'm setting some state handlers for notifications in our "slack-compatible" (i.e. Zulip) streams. However I'm getting some odd behaviour with the updates. The Flow
Copy code
with Flow('slack-test',state_handlers=[post_to_slack]) as flow_slack:
    ini_message="Some Init Message"
    #    
    post_slack_init(ini_message)
    #
    count()
We get the initial flow message start (
post_to_slack
notifies us in start/end/failure), but we don't get the "ini_message" until the flow ends. Even more if
count
task (wich also carries a state handler) fails we get the fail of the task in first place and then the
post_slack_init
(just a post request no state handler on this task) message. Any Clues? Thanks in advance!
1
a
there are 2 types of state handlers: 1. Flow-level - assigned to your Flow object - this is the one you are using - you get the notification/perform some action when the flow run changes the state as defined in your state handler 2. Task-level - assigned to your task object - you get the notification/perform some action when the task run changes the state as defined in your state handler
not sure if this answers your question if not, can you say more about what you are trying to do?
f
Hi @Anna Geller! Thanks for your answer 🙂! We are just throwing some notification to our stream channel to warn other guys wrt some GPU servers usage (We are currently running some heavy load - managed by prefect- on these and we want to just warn some users). I think that we have found the solution😄!, just set
upstream_task
dependence on some of the tasks seems to solved the behaviour (we are now having the correct messages order). Thanks again!
🙌 1
a
Nice work figuring this out and thanks so much for the update!