[New-bugs-announce] [issue38013] AsyncGenerator breaks when not iterated fully with RuntimeError("can't send non-None value to a just-started coroutine")

Michael Yoo report at bugs.python.org
Mon Sep 2 20:13:43 EDT 2019


New submission from Michael Yoo <michael at yoo.id.au>:

Version: Python 3.7.3

When I run this code:

import asyncio


class TestAsyncGenerator:
    def __init__(self):
        pass

    async def aiter(self):
        yield 1
        yield 2


async def main():
    gen = TestAsyncGenerator()
    async for number in gen.aiter():
        break


asyncio.run(main())

# unhandled exception during asyncio.run() shutdown
# task: <Task finished coro=<<async_generator_athrow without __name__>()> exception=RuntimeError("can't send non-None value to a just-started coroutine")>
# RuntimeError: can't send non-None value to a just-started coroutine


There is a warning message that I don't expect to see. I would expect breaking from an async iteration to behave as if breaking from a normal iteration - that is, no problems.

However, I see the warning message shown above. Am I missing something? Otherwise, I believe this is a bug. Thanks!

----------
components: asyncio
messages: 351044
nosy: Michael Yoo, asvetlov, yselivanov
priority: normal
severity: normal
status: open
title: AsyncGenerator breaks when not iterated fully with RuntimeError("can't send non-None value to a just-started coroutine")
type: behavior
versions: Python 3.7

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue38013>
_______________________________________


More information about the New-bugs-announce mailing list