Exemplo n.º 1
0
def _generator_coroutine(generator, func, args, kwargs):
    """
    kaa.generator support for kaa.coroutine
    """
    async = func(*args, **kwargs)
    while True:
        result = async.next()
        while isinstance(result, InProgress):
            try:
                result = async.send((yield result))
            except Exception, e:
                async.throw(*sys.exc_info())
        if result == NotFinished:
            yield result
        else:
            generator.send(result)
Exemplo n.º 2
0
def _process(generator, inprogress=None):
    """
    function to call next, step, or throw
    """
    if inprogress is not None:
        if inprogress._exception:
            inprogress._unhandled_exception = None
            return generator.throw(*inprogress._exception)
        return generator.send(inprogress._result)
    return generator.next()
Exemplo n.º 3
0
def _generator_threaded(generator, func, args, kwargs):
    """
    kaa.generator support for kaa.threaded
    """
    for g in func(*args, **kwargs):
        generator.send(g)