def wrapper(self, stream, *args, **kwargs):
    try:
        return f(self, stream, *args, **kwargs)
    finally:
        stream.exhaust()
def wrapper(self, stream, *args, **kwargs):
    try:
        return f(self, stream, *args, **kwargs)
    finally:
        stream.exhaust()