PATH:
usr
/
lib
/
python2.7
/
site-packages
/
azurelinuxagent
/
common
from threading import Lock, currentThread class _SingletonPerThreadMetaClass(type): """ A metaclass that creates a SingletonPerThread base class when called. """ _instances = {} _lock = Lock() def __call__(cls, *args, **kwargs): with cls._lock: obj_name = "%s__%s" % (cls.__name__, currentThread().getName()) # Object Name = className__threadName if obj_name not in cls._instances: cls._instances[obj_name] = super(_SingletonPerThreadMetaClass, cls).__call__(*args, **kwargs) return cls._instances[obj_name] class SingletonPerThread(_SingletonPerThreadMetaClass('SingleObjectPerThreadMetaClass', (object,), {})): # This base class calls the metaclass above to create the singleton per thread object. This class provides an # abstraction over how to invoke the Metaclass so just inheriting this class makes the # child class a singleton per thread (As opposed to invoking the Metaclass separately for each derived classes) # More info here - https://stackoverflow.com/questions/6760685/creating-a-singleton-in-python # # Usage: # Inheriting this class will create a Singleton per thread for that class # To delete the cached object of a class, call DerivedClassName.clear() to delete the object per thread # Note: If the thread dies and is recreated with the same thread name, the existing object would be reused # and no new object for the derived class would be created unless DerivedClassName.clear() is called explicitly to # delete the cache pass
[+]
..
[-] __init__.py
[edit]
[-] conf.py
[edit]
[-] dhcp.py
[edit]
[-] event.py
[edit]
[-] exception.py
[edit]
[-] future.py
[edit]
[-] logger.py
[edit]
[+]
osutil
[+]
protocol
[-] rdma.py
[edit]
[+]
utils
[-] version.py
[edit]
[-] interfaces.py
[edit]
[-] __init__.pyc
[edit]
[-] __init__.pyo
[edit]
[-] conf.pyc
[edit]
[-] conf.pyo
[edit]
[-] agent_supported_feature.pyc
[edit]
[-] dhcp.pyc
[edit]
[-] dhcp.pyo
[edit]
[-] agent_supported_feature.pyo
[edit]
[-] event.pyc
[edit]
[-] event.pyo
[edit]
[-] logcollector.py
[edit]
[-] exception.pyc
[edit]
[-] exception.pyo
[edit]
[-] future.pyc
[edit]
[-] future.pyo
[edit]
[-] logger.pyc
[edit]
[-] logger.pyo
[edit]
[-] rdma.pyc
[edit]
[-] rdma.pyo
[edit]
[-] version.pyc
[edit]
[-] version.pyo
[edit]
[-] cgroup.py
[edit]
[-] cgroupapi.py
[edit]
[-] cgroupconfigurator.py
[edit]
[-] cgroupstelemetry.py
[edit]
[-] datacontract.py
[edit]
[-] errorstate.py
[edit]
[-] telemetryevent.py
[edit]
[-] cgroup.pyc
[edit]
[-] cgroup.pyo
[edit]
[-] logcollector_manifests.py
[edit]
[-] cgroupapi.pyc
[edit]
[-] cgroupapi.pyo
[edit]
[-] persist_firewall_rules.pyo
[edit]
[-] cgroupconfigurator.pyc
[edit]
[-] cgroupconfigurator.pyo
[edit]
[-] agent_supported_feature.py
[edit]
[-] cgroupstelemetry.pyc
[edit]
[-] cgroupstelemetry.pyo
[edit]
[-] persist_firewall_rules.py
[edit]
[-] datacontract.pyc
[edit]
[-] datacontract.pyo
[edit]
[-] singletonperthread.py
[edit]
[-] errorstate.pyc
[edit]
[-] errorstate.pyo
[edit]
[-] AgentGlobals.pyo
[edit]
[-] AgentGlobals.pyc
[edit]
[-] telemetryevent.pyc
[edit]
[-] telemetryevent.pyo
[edit]
[-] AgentGlobals.py
[edit]
[-] interfaces.pyc
[edit]
[-] interfaces.pyo
[edit]
[-] singletonperthread.pyo
[edit]
[-] logcollector.pyc
[edit]
[-] logcollector.pyo
[edit]
[-] persist_firewall_rules.pyc
[edit]
[-] logcollector_manifests.pyc
[edit]
[-] logcollector_manifests.pyo
[edit]
[-] singletonperthread.pyc
[edit]