Browse Source

Coroutine

pull/3/head
Jure Šorn 6 years ago
parent
commit
daa5e88d63
1 changed files with 11 additions and 6 deletions
  1. 17
      README.md

17
README.md

@ -844,14 +844,19 @@ def eval_(node):
Coroutine
---------
**• Similar to Generator, but Generator pulls data through the pipe with iteration, while Coroutine pushes data into the pipeline with send().**
**• Coroutines provide more powerful data routing possibilities than iterators.
**• If you built a collection of simple data processing components, you can glue them together into complex arrangements of pipes, branches, merging, etc.**
**• Similar to Generator, but Generator pulls data through the pipe with iteration, while Coroutine pushes data into the pipeline with send().**
**• Coroutines provide more powerful data routing possibilities than iterators.**
**• If you built a collection of simple data processing components, you can glue them together into complex arrangements of pipes, branches, merging, etc.**
### Helper Decorator
**• All coroutines must be "primed" by first calling .next()**
**• Remembering to call .next() is easy to forget.**
**• Solved by wrapping coroutines with a decorator:**
**• All coroutines must be "primed" by first calling .next()**
**• Remembering to call .next() is easy to forget.**
**• Solved by wrapping coroutines with a decorator:**
```python
def coroutine(func):
def start(*args, **kwargs):

Loading…
Cancel
Save