Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AsyncGenerator breaks when not iterated fully with RuntimeError("can't send non-None value to a just-started coroutine") #82194

Closed
MichaelYoo mannequin opened this issue Sep 3, 2019 · 7 comments
Assignees
Labels
3.7 (EOL) end of life 3.8 only security fixes 3.9 only security fixes release-blocker topic-asyncio type-bug An unexpected behavior, bug, or error

Comments

@MichaelYoo
Copy link
Mannequin

MichaelYoo mannequin commented Sep 3, 2019

BPO 38013
Nosy @ned-deily, @asvetlov, @ambv, @1st1, @miss-islington, @tirkarthi
PRs
  • bpo-38013: Fix runtime error on closing async generator #16061
  • bpo-38013: make async_generator_athrow object tolerant to throwing exceptions #16070
  • [3.8] bpo-38013: make async_generator_athrow object tolerant to throwing exceptions (GH-16070) #16231
  • [3.7] bpo-38013: make async_generator_athrow object tolerant to throwing exceptions (GH-16070) #16232
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = 'https://github.com/asvetlov'
    closed_at = <Date 2019-09-17.13:20:51.172>
    created_at = <Date 2019-09-03.00:13:42.963>
    labels = ['type-bug', '3.8', '3.9', 'release-blocker', '3.7', 'expert-asyncio']
    title = 'AsyncGenerator breaks when not iterated fully with RuntimeError("can\'t send non-None value to a just-started coroutine")'
    updated_at = <Date 2019-09-17.13:20:51.171>
    user = 'https://bugs.python.org/MichaelYoo'

    bugs.python.org fields:

    activity = <Date 2019-09-17.13:20:51.171>
    actor = 'asvetlov'
    assignee = 'asvetlov'
    closed = True
    closed_date = <Date 2019-09-17.13:20:51.172>
    closer = 'asvetlov'
    components = ['asyncio']
    creation = <Date 2019-09-03.00:13:42.963>
    creator = 'Michael Yoo'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 38013
    keywords = ['patch', '3.7regression']
    message_count = 7.0
    messages = ['351044', '352486', '352598', '352603', '352634', '352636', '352637']
    nosy_count = 7.0
    nosy_names = ['ned.deily', 'asvetlov', 'lukasz.langa', 'yselivanov', 'miss-islington', 'xtreak', 'Michael Yoo']
    pr_nums = ['16061', '16070', '16231', '16232']
    priority = 'release blocker'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue38013'
    versions = ['Python 3.7', 'Python 3.8', 'Python 3.9']

    @MichaelYoo
    Copy link
    Mannequin Author

    MichaelYoo mannequin commented Sep 3, 2019

    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!

    @MichaelYoo MichaelYoo mannequin added 3.7 (EOL) end of life topic-asyncio type-bug An unexpected behavior, bug, or error labels Sep 3, 2019
    @asvetlov
    Copy link
    Contributor

    I have a PR for the fix.
    Yuri preliminary agrees with the patch but he requested more time for careful review.

    I've added 'release blocker' priority to don't miss this bugfix for the next release.

    @asvetlov asvetlov added 3.8 only security fixes 3.9 only security fixes release-blocker labels Sep 15, 2019
    @ned-deily
    Copy link
    Member

    I've added 'release blocker' priority to don't miss this bugfix for the next release.

    Note that 3.7.5rc1 is scheduled to be tagged today so we need to make a decision on whether to hold the release for a fix. From a quick test, it looks like the behavior was introduced in 3.7.1 as the test does not fail for me with 3.7.0. If so, that seems to meet the criteria for a maintenance release regression and thus potentially a release blocker.

    @asvetlov
    Copy link
    Contributor

    Thanks, Ned.
    I love to include this in 3.7.5.
    I've pinged Yuri offline with ask for review

    @miss-islington
    Copy link
    Contributor

    New changeset c275312 by Miss Islington (bot) (Andrew Svetlov) in branch 'master':
    bpo-38013: make async_generator_athrow object tolerant to throwing exceptions (GH-16070)
    c275312

    @miss-islington
    Copy link
    Contributor

    New changeset fc022f0 by Miss Islington (bot) in branch '3.7':
    bpo-38013: make async_generator_athrow object tolerant to throwing exceptions (GH-16070)
    fc022f0

    @miss-islington
    Copy link
    Contributor

    New changeset 3c1786f by Miss Islington (bot) in branch '3.8':
    bpo-38013: make async_generator_athrow object tolerant to throwing exceptions (GH-16070)
    3c1786f

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.7 (EOL) end of life 3.8 only security fixes 3.9 only security fixes release-blocker topic-asyncio type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    3 participants