changeset 3525:7f5bf108961a

tools (async_trigger): new `asyncReturnPoint` method
author Goffi <goffi@goffi.org>
date Wed, 05 May 2021 15:37:33 +0200
parents 584379473925
children e84ffb48acd4
files sat/tools/async_trigger.py
diffstat 1 files changed, 15 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/sat/tools/async_trigger.py	Wed May 05 15:37:33 2021 +0200
+++ b/sat/tools/async_trigger.py	Wed May 05 15:37:33 2021 +0200
@@ -52,3 +52,18 @@
             except sync_trigger.SkipOtherTriggers:
                 break
         defer.returnValue(True)
+
+    async def asyncReturnPoint(self, point_name, *args, **kwargs):
+        """Async version of returnPoint"""
+        if point_name not in self.__triggers:
+            return True
+
+        for priority, trigger in self.__triggers[point_name]:
+            try:
+                cont, ret_value = await utils.asDeferred(trigger, *args, **kwargs)
+                if not cont:
+                    return False, ret_value
+            except sync_trigger.SkipOtherTriggers:
+                break
+        return True, None
+