Spaces:
Build error
Build error
File size: 747 Bytes
24d2459 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
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
|