diff sat/tools/async_trigger.py @ 2650:3a8e7ec4648a

tools (trigger, async_trigger): added no_cancel argument to point and asyncPoint when a trigger must not be cancellable
author Goffi <goffi@goffi.org>
date Sat, 11 Aug 2018 18:24:52 +0200
parents f2cf1daa42cb
children 003b8b4b56a7
line wrap: on
line diff
--- a/sat/tools/async_trigger.py	Sat Aug 04 13:03:44 2018 +0200
+++ b/sat/tools/async_trigger.py	Sat Aug 11 18:24:52 2018 +0200
@@ -31,15 +31,22 @@
 
         All the triggers for that point will be run
         @param point_name: name of the trigger point
+        @param *args: args to transmit to trigger
+        @param *kwargs: kwargs to transmit to trigger
+            if "triggers_no_cancel" is present, it will be popped out
+                when set to True, this argument don't let triggers stop
+                the workflow
         @return D(bool): True if the action must be continued, False else
         """
         if point_name not in self.__triggers:
             defer.returnValue(True)
 
+        can_cancel = not kwargs.pop('triggers_no_cancel', False)
+
         for priority, trigger in self.__triggers[point_name]:
             try:
                 cont = yield trigger(*args, **kwargs)
-                if not cont:
+                if can_cancel and not cont:
                     defer.returnValue(False)
             except sync_trigger.SkipOtherTriggers:
                 break