portage.util.futures.compat_coroutine module¶
- exception portage.util.futures.compat_coroutine._CoroutineReturnValue(result)¶
Bases:
Exception
- args¶
- with_traceback()¶
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- class portage.util.futures.compat_coroutine._GeneratorTask(generator, result, loop)¶
Bases:
object
Asynchronously executes the generator to completion, waiting for the result of each Future that it yields, and sending the result to the generator.
- _cancel_callback(result)¶
- _next(previous=None)¶
- portage.util.futures.compat_coroutine._generator_future(generator_func, *args, **kwargs)¶
Call generator_func with the given arguments, and return a Future that is done when the resulting generation is exhausted. If a keyword argument named ‘loop’ is given, then it is used instead of the default event loop.
- portage.util.futures.compat_coroutine._iscoroutinefunction(func)¶
Return True if func is a decorated coroutine function created with the coroutine decorator for this module.
- portage.util.futures.compat_coroutine.coroutine(generator_func)¶
A decorator for a generator function that behaves as coroutine function. The generator should yield a Future instance in order to wait for it, and the result becomes the result of the current yield-expression, via the PEP 342 generator send() method.
The decorated function returns a Future which is done when the generator is exhausted. The generator can return a value via the coroutine_return function.
- Parameters
generator_func (function) – A generator function that yields Futures, and will receive the result of each Future as the result of the corresponding yield-expression.
- Return type
function
- Returns
A function which calls the given generator function and returns a Future that is done when the generator is exhausted.
- portage.util.futures.compat_coroutine.coroutine_return(result=None)¶
Terminate the current coroutine and set the result of the associated Future.
- Parameters
result – of the current coroutine’s Future
:type object