From 52df007926ef84be44eb767fcaee6175880b295b Mon Sep 17 00:00:00 2001 From: vzhestkov Date: Thu, 21 Mar 2024 10:31:26 +0100 Subject: [PATCH] Prevent possible exception in tornado.concurrent.Future._set_done --- salt/ext/tornado/concurrent.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/salt/ext/tornado/concurrent.py b/salt/ext/tornado/concurrent.py index bea09ba125e..011808ed272 100644 --- a/salt/ext/tornado/concurrent.py +++ b/salt/ext/tornado/concurrent.py @@ -330,12 +330,13 @@ def _check_done(self): def _set_done(self): self._done = True - for cb in self._callbacks: - try: - cb(self) - except Exception: - app_log.exception("Exception in callback %r for %r", cb, self) - self._callbacks = None + if self._callbacks: + for cb in self._callbacks: + try: + cb(self) + except Exception: + app_log.exception("Exception in callback %r for %r", cb, self) + self._callbacks = None # On Python 3.3 or older, objects with a destructor part of a reference # cycle are never destroyed. It's no longer the case on Python 3.4 thanks to