def locked(filename=None):
    """
    :param filename:
    :return: True if file is locked.
    """
    with open(filename, 'a') as fh:
        try:
            _flock(fh, LOCK_EX | LOCK_NB)
            ret = False
        except IOError as e:
            if e.errno == errno.EAGAIN:
                log.debug('{0} is locked: {1}'.format(filename, e))
                ret = True
            else:
                ret = False
    return ret
dataset/ETHPy150Open Netflix/aminator/aminator/util/linux.py/locked/original