def zauto(zero, loops, wait=False):
    'Keep listening and sending until the loop ends. All received objects are yielded.'
    try:
        if zero.setup.replies:
            for rep, msg in izip(loops, zero):
                yield msg
                zero(rep)
        elif zero.setup.transmits:
            for msg in loops:
                res = zero(msg)
                if zero.setup.yields:
                    yield res
        else:
            for _, msg in izip(loops, zero):
                yield msg
    except __HOLE__:
        zero.setup.debug('Quit by user')
    except StopIteration:
        zero.setup.debug('Loop ended')
    finally:
        if wait:
            raw_input('Press enter when done.')
        zero.setup.debug('Closing: %r', zero)
        zero.close()
dataset/ETHPy150Open philipbergen/zero/py/zero/__init__.py/zauto