diff sat/tools/async_trigger.py @ 3397:c069882f64cb

tools (async_trigger): use `utils.asDeferred` for async triggers: A corouting or blocking method can now be used for async triggers.
author Goffi <goffi@goffi.org>
date Thu, 12 Nov 2020 14:53:15 +0100
parents 559a625a236b
children be6d91572633
line wrap: on
line diff
--- a/sat/tools/async_trigger.py	Thu Nov 12 14:53:15 2020 +0100
+++ b/sat/tools/async_trigger.py	Thu Nov 12 14:53:15 2020 +0100
@@ -19,7 +19,8 @@
 
 """Misc usefull classes"""
 
-from sat.tools import trigger as sync_trigger
+from . import trigger as sync_trigger
+from . import utils
 from twisted.internet import defer
 
 class TriggerManager(sync_trigger.TriggerManager):
@@ -45,7 +46,7 @@
 
         for priority, trigger in self.__triggers[point_name]:
             try:
-                cont = yield trigger(*args, **kwargs)
+                cont = yield utils.asDeferred(trigger, *args, **kwargs)
                 if can_cancel and not cont:
                     defer.returnValue(False)
             except sync_trigger.SkipOtherTriggers: