how can i get the state of a task from a task obje...
# ask-community
z
how can i get the state of a task from a task object?
for context my use case is i want a state handler at the flow level, but i want to send a slack message that says which tasks failed and which were successful
e.g
Copy code
def my_flow_state_handler(flow, old_state, new_state):
    a_task_state = flow.get_tasks(name="my_task")[0].whatdoido
@Kevin Kho any ideas?
k
Hey @Zach Schumacher. A couple of things. You can use a terminal state handler if you want to work with the final state of the flow. I think we don’t keep track of all state changes of each individual task and I don’t think you can call it like that but I have to double check.
z
looks like that gets me closer to what i want, does a state know the name of a task its associated with?
state changes for tasks aren’t neccesarily important, just when the flow goes from running to success or failed, want to be able to say all tasks were successful or task “my task” failed
k
I was trying this last night and didn’t see an immediate way so I have to ask the team and get back to you