def open_file(path, mode):
    """
    Attempts to open file at path.
    Tried up to max_attempts times because of intermittent permission errors on windows
    """
    max_attempts = 100
    f = None
    for _ in range(max_attempts): # pragma: no branch
        try:
            f = open(path, mode)
        except PermissionError: # pragma: no cover
            continue
        break
    return f