单例模式:
class sign_mode(object):
objs = {} obj_last = threading.Lock() def __new__(cls, *args, **kwargs): if cls in cls.objs: return cls.objs[cls] cls.obj_last.acquire() try: cls.objs[cls] = super(sign_mode, cls).__new__(cls, *args, **kwargs) finally: cls.obj_last.release() return cls.objs[cls]