def pump(type_):
    """
    Feed the generator into *type_* til exhaustion. Can be overridden by
    setting exhaust=False.
    """

    def _pump(f):
        def fx(*args, **kwargs):
            exhaust_gen = kwargs.pop("exhaust", True)
            gen = f(*args, **kwargs)
            if exhaust_gen:
                return type_(gen)
            return gen

        return fx

    return _pump