From 221e0f232be0ceb5c00560ec03e5f6afa0c49e81 Mon Sep 17 00:00:00 2001 From: Jakob Ketterl Date: Mon, 27 Dec 2021 16:37:10 +0100 Subject: [PATCH] try to avoid "can only be started once" error --- owrx/cpu.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/owrx/cpu.py b/owrx/cpu.py index cad912f..e296426 100644 --- a/owrx/cpu.py +++ b/owrx/cpu.py @@ -22,6 +22,7 @@ class CpuUsageThread(threading.Thread): self.last_worktime = 0 self.last_idletime = 0 self.endEvent = threading.Event() + self.startLock = threading.Lock() super().__init__() def run(self): @@ -59,8 +60,9 @@ class CpuUsageThread(threading.Thread): def add_client(self, c): self.clients.append(c) - if not self.is_alive(): - self.start() + with self.startLock: + if not self.is_alive(): + self.start() def remove_client(self, c): try: