

def does_file_exist(fname):
    "Figure out if we'll be able to read this file.\n\n    Because we are handling the file streams as generators, we actually raise\n    an exception too late for us to be able to handle it before apache has\n    completely control. This attempts to do the same open outside of the\n    generator to trigger the IOError early enough for us to catch it, without\n    completely changing the logic flow, as we really want the generator\n    pipeline for performance reasons.\n\n    This does open us up to a small chance for a race where the file comes\n    or goes between this call and the next, however that is a vanishingly\n    small possibility.\n    "
    try:
        f = open(fname)
        f.close()
        return True
    except IOError:
        return False

dataset/ETHPy150Open openstack-infra/os-loganalyze/os_loganalyze/generator.py does_file_exist/original