[ANN] async_generator v1.2 released

Nathaniel Smith njs at pobox.com
Tue Nov 15 01:52:23 EST 2016


Hi all,

I just released v1.2 of my async_generator package:

  https://pypi.org/pypi/async_generator/

This package makes it easy to write PEP 525-style "async generators",
even on Python 3.5. It looks like:

    from async_generator import async_generator, yield_, yield_from_

    @async_generator
    async def parse_json_separated_newlines_from_network(streamreader):
        async for line in streamreader:
            await yield_(json.loads(line))

Starting in v1.1 (released last week but not announced widely), the
generators are now highly compatible with 3.6's native async
generators, including full support for athrow / asend / aclose. They
also fully support "yield from", which is otherwise unavailable even
on Python 3.6.

v1.2 fixed some edge cases in "yield from" -- but the headline feature
is that we're now *so* compatible with 3.6's native async generators
that you can now use our yield from support directly inside a native
generator:

    from async_generator import yield_from_

    async def f():
        yield 2
        yield 3

    # yields [1, 2, 3, 4]
    async def g():
        yield 1
        await yield_from_(f())
        yield 4

Have fun,
-n

-- 
Nathaniel J. Smith -- https://vorpus.org


More information about the Python-announce-list mailing list