def synchronized(obj = None):
    """ 
        Synchronization decorator. 
        Modified to support both synchronizing on an existing lock and on
        an object which owns a __dict__
    """
    
    
    if type(obj).__name__ not in (threading.Lock.__name__, threading.RLock.__name__):
        lk = threading.Lock()
        obj.__dict__["__sync_lock"] = lk
        obj = lk
        
    

    def wrap_lock(f):
        def newFunction(*args, **kw):
            obj.acquire()
            try:
                return f(*args, **kw)
            finally:
                obj.release()
        return newFunction
            
    return wrap_lock
dataset/ETHPy150Open weblabdeusto/weblabdeusto/tools/ExperimentServerTester/src/threaded.py/synchronized/original