improve cpu usage thread instance protection

This commit is contained in:
Jakob Ketterl 2021-01-09 20:01:39 +01:00
parent 113c06fae4
commit 502546f9d3

View File

@ -23,6 +23,7 @@ class CpuUsageThread(threading.Thread):
self.last_idletime = 0
self.endEvent = threading.Event()
super().__init__()
self.start()
def run(self):
logger.debug("cpu usage thread starting up")
@ -59,8 +60,6 @@ class CpuUsageThread(threading.Thread):
def add_client(self, c):
self.clients.append(c)
if not self.is_alive():
self.start()
def remove_client(self, c):
try:
@ -71,6 +70,7 @@ class CpuUsageThread(threading.Thread):
self.shutdown()
def shutdown(self):
CpuUsageThread.sharedInstance = None
with CpuUsageThread.creationLock:
CpuUsageThread.sharedInstance = None
self.doRun = False
self.endEvent.set()