code: def Lock(fd, path, blocking):
    
    operation = fcntl.LOCK_EX if blocking else fcntl.LOCK_EX | fcntl.LOCK_NB
    try:
      fcntl.flock(fd, operation)
    except IOError as e:
      if e.errno == errno.EWOULDBLOCK:
        raise IOError('Exception locking %s. File already locked.' % path)
      else:
        raise IOError('Exception locking %s. %s.' % (path, str(e)))
docs: Lock the provided file descriptor.
  
    Args:
      fd: int, the file descriptor of the file to lock.
      path: string, the name of the file to lock.
      blocking: bool, whether the function should return immediately.
  
    Raises:
      IOError, raised from flock while attempting to lock a file.