def __next__(self):
    if (self.queue is None):
        raise StopIteration
    (yields, value) = self.queue.get()
    if yields:
        return value
    else:
        self.queue = None
        raise value
def __next__(self):
    if (self.queue is None):
        raise StopIteration
    (yields, value) = self.queue.get()
    if yields:
        return value
    else:
        self.queue = None
        raise value