2022-03-09 13:17:33 +08:00
|
|
|
import _thread
|
2022-03-18 17:53:46 +08:00
|
|
|
from misc import Power
|
2022-03-11 09:49:24 +08:00
|
|
|
|
2022-03-09 13:17:33 +08:00
|
|
|
|
|
|
|
class Singleton(object):
|
|
|
|
_instance_lock = _thread.allocate_lock()
|
|
|
|
|
|
|
|
def __init__(self, *args, **kwargs):
|
|
|
|
pass
|
|
|
|
|
|
|
|
def __new__(cls, *args, **kwargs):
|
|
|
|
if not hasattr(cls, 'instance_dict'):
|
|
|
|
Singleton.instance_dict = {}
|
|
|
|
|
|
|
|
if str(cls) not in Singleton.instance_dict.keys():
|
|
|
|
with Singleton._instance_lock:
|
|
|
|
_instance = super().__new__(cls)
|
|
|
|
Singleton.instance_dict[str(cls)] = _instance
|
|
|
|
|
|
|
|
return Singleton.instance_dict[str(cls)]
|
2022-03-18 17:53:46 +08:00
|
|
|
|
|
|
|
|
|
|
|
def numiter():
|
|
|
|
for i in range(99999):
|
|
|
|
yield i
|
|
|
|
|
|
|
|
|
|
|
|
def power_restart():
|
|
|
|
Power.powerRestart()
|