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

def exhaust_stream ( f ) : def wrapper ( self , stream , * args , ** kwargs ) : try : return f ( self , stream , * args , ** kwargs ) finally : stream . exhaust ( ) return update_wrapper ( wrapper , f )
helper decorator for methods that exhausts the stream on return .