prevent multiple creation of cpu usage thread
This commit is contained in:
parent
90f319ebda
commit
a1cbc45b88
@ -7,9 +7,11 @@ logger = logging.getLogger(__name__)
|
|||||||
|
|
||||||
class CpuUsageThread(threading.Thread):
|
class CpuUsageThread(threading.Thread):
|
||||||
sharedInstance = None
|
sharedInstance = None
|
||||||
|
creationLock = threading.Lock()
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def getSharedInstance():
|
def getSharedInstance():
|
||||||
|
with CpuUsageThread.creationLock:
|
||||||
if CpuUsageThread.sharedInstance is None:
|
if CpuUsageThread.sharedInstance is None:
|
||||||
CpuUsageThread.sharedInstance = CpuUsageThread()
|
CpuUsageThread.sharedInstance = CpuUsageThread()
|
||||||
return CpuUsageThread.sharedInstance
|
return CpuUsageThread.sharedInstance
|
||||||
|
Loading…
Reference in New Issue
Block a user