While yes, running a coroutine in a new task is in the standard library, that is only a component of what this library does, which is:
- given an async iterable,
- iterating over it in a new task, into a buffer,
- and then returning an iterable that yields values from this buffer as it's filled.
I don't _think_ this logic is in the standard library, at least not at https://docs.python.org/3/library/asyncio-task.html#asyncio.... from what I can see.
Have you thought about making it work as a decorator?
The issue is what happens on exceptions to avoid tasks hanging around forever. Exceptions propagate “forward” in the pipeline fairly automatically. However, getting the ones “behind” the exception to notice: that was tricky. The best I came up with was the bit of state wrapped up in buffered_pipeline that notices the exceptions and cancels the tasks.
I've gotten along ok with create_task and gather. I'll need to spend some time with this implementation to see if it fits any of my existing asyncio coding patterns.