pep-492: Add a small example for types.coroutine
This commit is contained in:
parent
12845432a7
commit
7056d7f540
|
@ -137,7 +137,12 @@ types.coroutine()
|
|||
|
||||
A new function ``coroutine(gen)`` is added to the ``types`` module. It
|
||||
allows interoperability between existing *generator-based coroutines*
|
||||
in asyncio and *native coroutines* introduced by this PEP.
|
||||
in asyncio and *native coroutines* introduced by this PEP::
|
||||
|
||||
@types.coroutine
|
||||
def process_data(db):
|
||||
data = yield from read_data(db)
|
||||
...
|
||||
|
||||
The function applies ``CO_ITERABLE_COROUTINE`` flag to generator-
|
||||
function's code object, making it return a *coroutine* object.
|
||||
|
|
Loading…
Reference in New Issue