class GeneratorContainer:

    def __init__(self, generator, length):
        self.generator = generator
self.length = length

def __iter__(self):
    return self.generator

def __len__(self):
    return self.length
result = GeneratorContainer(DBProcessor().get_listings(), length)
Python how to turn a result of a method into generator