From 740063c23b1fe755975156992728b231c6e29e52 Mon Sep 17 00:00:00 2001 From: Fabio Manganiello Date: Sun, 13 Jan 2019 22:58:18 +0100 Subject: [PATCH] Clear the timeout handler from the map once the execution is terminated --- platypush/plugins/utils.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/platypush/plugins/utils.py b/platypush/plugins/utils.py index 90f0807b2f..fe494cd671 100644 --- a/platypush/plugins/utils.py +++ b/platypush/plugins/utils.py @@ -59,12 +59,16 @@ class UtilsPlugin(Plugin): return (None, "A timeout named '{}' is already awaiting".format(name)) - procedure = Procedure.build(name=name, requests=actions, _async=False) self._pending_timeouts[name] = procedure def _proc_wrapper(**kwargs): - procedure.execute(**kwargs) + try: + procedure.execute(**kwargs) + finally: + with self._pending_timeouts_lock: + if name in self._pending_timeouts: + del self._pending_timeouts[name] with self._pending_timeouts_lock: self._pending_timeouts[name] = threading.Timer(seconds, @@ -78,6 +82,7 @@ class UtilsPlugin(Plugin): with self._pending_timeouts_lock: if name not in self._pending_timeouts: + self.logger.debug('{} is not a pending timeout'.format(name)) return timer = self._pending_timeouts.pop(name) @@ -138,6 +143,7 @@ class UtilsPlugin(Plugin): with self._pending_intervals_lock: if name not in self._pending_intervals: + self.logger.debug('{} is not a running interval'.format(name)) return del self._pending_intervals[name]