vxgmichel / aiostream

Generator-based operators for asynchronous iteration
http://aiostream.readthedocs.io
GNU General Public License v3.0
778 stars 34 forks source link

How to create a stream from a list #29

Closed JerzySpendel closed 6 years ago

JerzySpendel commented 6 years ago

I want to create a stream from a simple list, let's say [1, 2, 3]. How do I do that? What I managed to do is:

@operator
async def out():
    for x in [1,2,3]:
        yield x

async def main():

    async for x in out():
        print(x)

If this is the simplest way I would suggest ehancing somehow operator function to accept a synchronous iterables or creating a dedicated function for that.

JerzySpendel commented 6 years ago

Ok. there's a stream.iterate function