From abbd8409cabe7261b294604a0d36ffa1666ea984 Mon Sep 17 00:00:00 2001 From: Fabio Manganiello Date: Wed, 28 Nov 2018 01:01:16 +0100 Subject: [PATCH] Run event hook actions in another thread --- platypush/event/hook.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/platypush/event/hook.py b/platypush/event/hook.py index ceddf09a..c7314e9e 100644 --- a/platypush/event/hook.py +++ b/platypush/event/hook.py @@ -2,6 +2,7 @@ import copy import json import logging import re +import threading from platypush.config import Config from platypush.message.event import Event, EventMatchResult @@ -148,13 +149,15 @@ class EventHook(object): """ Checks the condition of the hook against a particular event and runs the hook actions if the condition is met """ + def _thread_func(result): + self.actions.execute(event=event, **result.parsed_args) + result = self.matches_event(event) token = Config.get('token') if result.is_match: logger.info('Running hook {} triggered by an event'.format(self.name)) - # TODO here event should actually be event.args - self.actions.execute(event=event, **result.parsed_args) + threading.Thread(target=_thread_func, args=(result,)).start() # vim:sw=4:ts=4:et: