Hi, I want to let your know about the Retry. This is a new feature in Taskflow. Retry allows to execute a flow or a part of a flow several times if it fails. Retry is very similar to task and it can be executed or reverted, it accepts and returns values in the similar way as a Task. And it has 'on_failure' method that allow to handle flow failure and make a decision to revert a flow or revert only a failed part and retry it again. Retry has a 'history' parameter, this is a history of all previous results returned by this retry and flow failures raised on each previous try.
There is an example of Retry that retries a flow if some error has been raised by the task and reverts a flow if CriticalError has been raised. class SimpleRetry(Retry): def on_failure(self, history, *args, **kwargs): # History is a list of tupes (retry_result, {'task_name': misc.Failure}) # retry_result is the result returned by retry execute method # 'task_name' is the name of failed task in curent subflow # misc.Failure is an object that wraps raised exception # This code fetches a dictionary of latest errors last_errors = history[-1][1] # Check errors' types for task_name, failure in last_errors.items(): # Revert a flow if CriticalError has occurred if failure.check(CriticalError): return REVERT # Retry a flow if any other error occurred return RETRY def execute(self, history, *args, **kwargs): attempt = len(history)+1 print "Retry a flow %s times" % attempt return attempt def revert(self, history, *args, **kwargs): print "Reverting a flow" There is an example a flow with Retry: flow = linear_flow.Flow("my_flow", retry = SimpleRetry("my_retry)).add(Task1(), Task2()) In case of Task1 or Task2 failure SimpleRetry.on_failure method will be called. If the retry returns RETRY then Task1 and Task2 will be reverted and SimpleRetry and tasks will be executed again, otherwise the whole flow will be reverted. There are some predefined retries that can be easily used in most common cases. You can find the base Retry class and all predefined retries in the taskflow.retry package. Example of usage of Retry can be found in taskflow.examples.retry_flow.pyfile. Wiki page is here https://wiki.openstack.org/wiki/TaskFlow/Retry Thanks! Anastasia
_______________________________________________ OpenStack-dev mailing list OpenStack-dev@lists.openstack.org http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev