Coroutine related boilerplate and wrappers.
Bases: object
A threadlocal-like object that works in the context of coroutines. That means, the current running coroutine has the _ident_.
Coroutine.run_op sets the indent before running a step and unsets after.
Example:
loc = local()
loc.foo = 1
The loc instance’s values will be different for separate coroutines.
Bases: object
A decorator function for generators. Example:
@coroutine
def plain_ol_generator():
yield bla
yield bla
...
Bases: cogen.core.events.Operation
We need a coroutine wrapper for generators and functions alike because we want to run functions that don’t return generators just like a coroutine, also, we do some exception handling here.
Handle the operation:
Return self is used as a optimization. Coroutine is also a Operation which handles it’s own completion (resuming the caller and the waiters).
Bases: exceptions.Exception
This is used intenally to carry exception state in the poller and scheduler.