code: def with_lock(lock):
    
    def decorator(func):
      @functools.wraps(func)
      def _with_lock(*args, **kwargs):
        with lock:
          return func(*args, **kwargs)
      return _with_lock
    return decorator
docs: Make sure the lock is held while in this function.