def _gen_wrapper(ctx, generator):
    """Generator Wrapper that starts/stops our context
    """
    try:
        yielded = None
        while True:
            ctx.start()

            value = generator.send(yielded)

            ctx.stop()

            try:
                yielded = yield value
            except Exception:
                ctx.start()
                value = generator.throw(*sys.exc_info())
                ctx.stop()

                yielded = yield value

    except (tornado.gen.Return, __HOLE__):
        ctx.done()
        raise
dataset/ETHPy150Open rhettg/BlueOx/blueox/tornado_utils.py/_gen_wrapper