Classes

Functions

Module: cogen.core.coroutines

Coroutine related boilerplate and wrappers.

Classes

Coroutine

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.

local

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.

Functions

coroutine (func)

A decorator function for generators. Example:

@coroutine
def plain_ol_generator():
    yield bla
    yield bla
    ...