<s> """<STR_LIT>""" <EOL> import logging <EOL> import threading <EOL> log = logging . getLogger ( __name__ ) <EOL> class SingletonMetaclass ( type ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( cls , * args , ** kwargs ) : <EOL> super ( SingletonMetaclass , cls ) . __init__ ( * args , ** kwargs ) <EOL> cls . __instance = None <EOL> cls . __lock = threading . RLock ( ) <EOL> def __call__ ( cls , * args , ** kwargs ) : <EOL> with cls . __lock : <EOL> if cls . __instance is None : <EOL> cls . __instance = super ( SingletonMetaclass , cls ) . __call__ ( <EOL> * args , ** kwargs ) <EOL> return cls . __instance </s>
