Mercurial > libervia-backend
changeset 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 | a4774f5b6b17 |
children | 467d6c709f1d |
files | sat/tools/async_trigger.py |
diffstat | 1 files changed, 3 insertions(+), 2 deletions(-) [+] |
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: