From a083b950213af93617c0a72bfbd4975de321076c Mon Sep 17 00:00:00 2001 From: SomberNight Date: Fri, 9 Feb 2024 13:48:51 +0000 Subject: [PATCH] util.CallbackManager: handle callbacks being cancelled was getting log spam when running the pycharm debugger in certain cases: ``` 3.29 | E | concurrent.futures | exception calling callback for Traceback (most recent call last): File "...\Python310\lib\concurrent\futures\_base.py", line 342, in _invoke_callbacks callback(self) File "...\electrum\electrum\util.py", line 1785, in on_done if exc := fut_.exception(): File "...\Python310\lib\concurrent\futures\_base.py", line 485, in exception raise CancelledError() concurrent.futures._base.CancelledError ``` --- electrum/util.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/electrum/util.py b/electrum/util.py index 5cdad713b..8f8b9219a 100644 --- a/electrum/util.py +++ b/electrum/util.py @@ -1782,7 +1782,9 @@ class CallbackManager(Logger): def on_done(fut_: concurrent.futures.Future): assert fut_.done() self._running_cb_futs.remove(fut_) - if exc := fut_.exception(): + if fut_.cancelled(): + self.logger.debug(f"cb cancelled. {event=}.") + elif exc := fut_.exception(): self.logger.error(f"cb errored. {event=}. {exc=}", exc_info=exc) fut.add_done_callback(on_done) else: # non-async cb