import fcntl


def has_flock(fd):
    """
    Checks if fd has flock over it
    True if it is, False otherwise
    :param fd:
    :return:
    :rtype: bool
    """
    try:
        fcntl.flock(fd, fcntl.LOCK_EX | fcntl.LOCK_NB)
    except BlockingIOError:
        return True
    else:
        return False