@utils.synchronized('safe_set_attr')
def set_safe_attr(instance, attr, val):
 if ((not instance) or (not attr)):
  return False
 old_val = getattr(instance, attr, None)
 if ((val is None) and (old_val is None)):
  return False
 elif (val == old_val):
  return False
 else:
  setattr(instance, attr, val)
  return True

@ utils . synchronized ( 'safe_set_attr' ) def set_safe_attr ( instance , attr , val ) : if ( ( not instance ) or ( not attr ) ) : return False old_val = getattr ( instance , attr , None ) if ( ( val is None ) and ( old_val is None ) ) : return False elif ( val == old_val ) : return False else : setattr ( instance , attr , val ) return True
sets the attribute in a thread safe manner .