class atomicObject(object):

    def __init__(self, obj):
        self.lock = threading.Lock()
self.obj = obj

def __getattr__(self, name):
    attr = getattr(self.obj, name)
print(attr)
if callable(attr):

    def atomized(*args, **kwargs):
        with self.lock:
            attr(*args, **kwargs)
return atomized
return attr
Как украсить объект Python мьютексом