code: def require(self, lock, guard_func, *guard_args, **guard_kw):
          
          def decorator(f):
              @wraps(f)
              def wrapper(*args, **kw):
                  if self.granted(lock):
                      self.msg('Granted {}'.format(lock))
                      return f(*args, **kw)
                  if guard_func(*guard_args, **guard_kw) and self.acquire(lock):
                      return f(*args, **kw)
                  return None
              return wrapper
          return decorator
docs: Decorate a function to be run only when a lock is acquired.
  
          The lock is requested if the guard function returns True.
  
          The decorated function is called if the lock has been granted.