diff --git a/electrum/plugin.py b/electrum/plugin.py index 8879e15a7..a2f7bff8f 100644 --- a/electrum/plugin.py +++ b/electrum/plugin.py @@ -209,7 +209,7 @@ class Plugins(DaemonThread): def run(self): while self.is_running(): - time.sleep(0.1) + self.wake_up_event.wait(0.1) # time.sleep(0.1) OR event self.run_jobs() self.on_stop() diff --git a/electrum/util.py b/electrum/util.py index cbf8a6a30..678aa9d9e 100644 --- a/electrum/util.py +++ b/electrum/util.py @@ -372,6 +372,7 @@ class DaemonThread(threading.Thread, Logger): self.jobs = [] self.stopped_event = threading.Event() # set when fully stopped self.stopped_event_async = asyncio.Event() # set when fully stopped + self.wake_up_event = threading.Event() # for perf optimisation of polling in run() def add_jobs(self, jobs): with self.job_lock: @@ -405,6 +406,8 @@ class DaemonThread(threading.Thread, Logger): def stop(self): with self.running_lock: self.running = False + self.wake_up_event.set() + self.wake_up_event.clear() def on_stop(self): if 'ANDROID_DATA' in os.environ: