def METHOD_NAME(func, *args, **kwargs):
    try:
        return func(*args, **kwargs)
    except OSError as e:
        if e.errno != 5:
            raise
    except ValueError as e:
        if "closed" not in str(e):
            raise