def execute_generator(gen):
    exc_info = None
    result = None
    while True:
        try:
            if exc_info:
                result = failure.throw(*exc_info)
                exc_info = None
            else:
                result = gen.send(result)
        except __HOLE__:
            break
        except Exception:
            if not exc_info:
                exc_info = sys.exc_info()
            else:
                break
        else:
            if isgenerator(result):
                result = execute_generator(result)
    #
    if exc_info:
        raise_error_trace(exc_info[1], exc_info[2])
    else:
        return result
dataset/ETHPy150Open lsbardel/python-stdnet/stdnet/backends/__init__.py/execute_generator