From a1cbc45b884871635b6f658336cd166575b9e4d5 Mon Sep 17 00:00:00 2001 From: Jakob Ketterl Date: Thu, 31 Dec 2020 23:18:01 +0100 Subject: [PATCH] prevent multiple creation of cpu usage thread --- owrx/cpu.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/owrx/cpu.py b/owrx/cpu.py index 28c9066..9405b8f 100644 --- a/owrx/cpu.py +++ b/owrx/cpu.py @@ -7,11 +7,13 @@ logger = logging.getLogger(__name__) class CpuUsageThread(threading.Thread): sharedInstance = None + creationLock = threading.Lock() @staticmethod def getSharedInstance(): - if CpuUsageThread.sharedInstance is None: - CpuUsageThread.sharedInstance = CpuUsageThread() + with CpuUsageThread.creationLock: + if CpuUsageThread.sharedInstance is None: + CpuUsageThread.sharedInstance = CpuUsageThread() return CpuUsageThread.sharedInstance def __init__(self):