URI: 
       tutil: document CallbackManager behaviour - electrum - Electrum Bitcoin wallet
  HTML git clone https://git.parazyd.org/electrum
   DIR Log
   DIR Files
   DIR Refs
   DIR Submodules
       ---
   DIR commit 28a7d204ad6e8bfa503f9f8afe2b8f23cb16238e
   DIR parent 533d796a4149cac7038ae5503e6c089de60ba614
  HTML Author: SomberNight <somber.night@protonmail.com>
       Date:   Thu, 11 Mar 2021 18:50:59 +0100
       
       util: document CallbackManager behaviour
       
       Diffstat:
         M electrum/util.py                    |       8 +++++++-
       
       1 file changed, 7 insertions(+), 1 deletion(-)
       ---
   DIR diff --git a/electrum/util.py b/electrum/util.py
       t@@ -1380,7 +1380,9 @@ def randrange(bound: int) -> int:
        
        
        class CallbackManager:
       -        # callbacks set by the GUI
       +    # callbacks set by the GUI or any thread
       +    # guarantee: the callbacks will always get triggered from the asyncio thread.
       +
            def __init__(self):
                self.callback_lock = threading.Lock()
                self.callbacks = defaultdict(list)      # note: needs self.callback_lock
       t@@ -1398,6 +1400,10 @@ class CallbackManager:
                            callbacks.remove(callback)
        
            def trigger_callback(self, event, *args):
       +        """Trigger a callback with given arguments.
       +        Can be called from any thread. The callback itself will get scheduled
       +        on the event loop.
       +        """
                if self.asyncio_loop is None:
                    self.asyncio_loop = asyncio.get_event_loop()
                    assert self.asyncio_loop.is_running(), "event loop not running"