xfh's picture
init
24d2459
raw
history blame contribute delete
747 Bytes
import threading
class SingletonRunningState:
_instance_lock = threading.Lock()
def __init__(self):
self.has_running = False
@classmethod
def instance(cls, *args, **kwargs):
with SingletonRunningState._instance_lock:
if not hasattr(SingletonRunningState, "_instance"):
print(f"instance")
SingletonRunningState._instance = SingletonRunningState(*args, **kwargs)
return SingletonRunningState._instance
def get_has_running(self):
with SingletonRunningState._instance_lock:
return self.has_running
def set_has_running(self, has_running):
with SingletonRunningState._instance_lock:
self.has_running = has_running