Index: leahi_dialin/ui/utils.py =================================================================== diff -u -r9f44c02ff3f40812ab9fd7f9c7346f649a114c19 -r126c206228086fbd13e820980c2fbb2fb58131bb --- leahi_dialin/ui/utils.py (.../utils.py) (revision 9f44c02ff3f40812ab9fd7f9c7346f649a114c19) +++ leahi_dialin/ui/utils.py (.../utils.py) (revision 126c206228086fbd13e820980c2fbb2fb58131bb) @@ -17,23 +17,25 @@ import time import struct from subprocess import check_output +import threading -def singleton(cls): +def singleton_threadsafe(cls): """ This is a singleton decorator Returns: cls: as for defintion of the singleton, it created the class instance once and will return on each access, instead of the recreation. """ instances = {} + lock = threading.Lock() def get_instance(*args, **kwargs): - if cls not in instances: - instances[cls] = cls(*args, **kwargs) + with lock: + if cls not in instances: + instances[cls] = cls(*args, **kwargs) return instances[cls] return get_instance - def srsui(vstr=""): """ for user convenience if wanted to put a note for the SRSUI