def synchronous(tlockname):
 def _synched(func):
  @wraps(func)
  def _synchronizer(self, *args, **kwargs):
   with self.__getattribute__(tlockname):
    return func(self, *args, **kwargs)
  return _synchronizer
 return _synched

def synchronous ( tlockname ) : def _synched ( func ) : @ wraps ( func ) def _synchronizer ( self , * args , ** kwargs ) : with self . __getattribute__ ( tlockname ) : return func ( self , * args , ** kwargs ) return _synchronizer return _synched
a decorator to place an instance-based lock around a method .