def __iter__(self):
    return self

def next(self):
    return next(self.iterator)

def close(self):
    if self.on_finish is not None:
        self.on_finish()
Implementing a WSGI Streaming Service: (how to detect client disconnects)