GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — `asyncio.wait(aws)` require aws is 'iterable', but doesn't accept `generator` · Issue #99936 · python/cpython

asyncio.wait(aws) require aws is 'iterable', but doesn't accept generator #99936

New issue
Copy link
New issue
Copy link
Closed as not planned
Closed as not planned
asyncio.wait(aws) require aws is 'iterable', but doesn't accept generator#99936
Copy link
Labels
topic-asynciotype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

Description

@NewUserHa
NewUserHa
opened on Dec 1, 2022
Issue body actions

Bug report

cpython/Lib/asyncio/tasks.py

Lines 407 to 409 in 0563be2

"""
if futures.isfuture(fs) or coroutines.iscoroutine(fs):
raise TypeError(f"expect a list of futures, not {type(fs).__name__}")

https://docs.python.org/3/library/asyncio-task.html#waiting-primitives
https://docs.python.org/3/glossary.html#term-iterable
asyncio.wait(aws) require aws is 'iterable' but doesn't accept generator while which is iterable ( has iter and next methods):

await asyncio.wait(asyncfunc(_) for _ in range())

Activity

  1. NewUserHa
    added
    type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
    on Dec 1, 2022
  2. JelleZijlstra commented on Dec 1, 2022

    @JelleZijlstra
    JelleZijlstra
    on Dec 1, 2022
    Member
    More actions

    This is because generators are in asyncio.coroutines._COROUTINE_TYPES: https://github.com/python/cpython/blob/main/Lib/asyncio/coroutines.py#L28. Therefore, asyncio.coroutines.iscoroutine thinks every generator is a coroutine.

    This is presumably a holdover from generator-based coroutines, which no longer exist in recent versions of asyncio. We should consider removing GeneratorType from _COROUTINE_TYPES, but we'll have to think about whether there are any backward compatibility implications.

  3. NewUserHa commented on Dec 1, 2022

    @NewUserHa
    NewUserHa
    on Dec 1, 2022
    ContributorAuthor
    More actions

    a more thing:
    I also see "DeprecationWarning: The explicit passing of coroutine objects to asyncio.wait() is deprecated since Python 3.8, and scheduled for removal in Python 3.11.".
    It didn't say anything, but I guess it's asking users to .create_task() outside .wait() for comparing if the task is in the returned done set. But the document of .wait() deleted that comparing part from the example code.
    It seems to make a little confuse both in DeprecationWarning and the document because they didn't match.

    maybe should update the document to match the warning?

  4. kumaraditya303
    added
    topic-asyncio
    on Dec 2, 2022
  5. ezio-melotti
    added this to asyncioon Dec 2, 2022
  6. ezio-melotti
    moved this to Todo in asyncioon Dec 2, 2022
  7. kumaraditya303 commented on Dec 2, 2022

    @kumaraditya303
    kumaraditya303
    on Dec 2, 2022
    Contributor
    More actions

    Duplicate of #78530

  8. kumaraditya303
    marked this as a duplicate of asyncio.wait should accept generator of tasks as first argument #78530 on Dec 2, 2022
  9. kumaraditya303
    closed this as not plannedon Dec 2, 2022
  10. Repository owner moved this from Todo to Done in asyncioon Dec 2, 2022
  11. NewUserHa commented on Dec 2, 2022

    @NewUserHa
    NewUserHa
    on Dec 2, 2022
    ContributorAuthor
    More actions

    I have seen #78530 when open issue. However, this issue is more about the document.

  12. kumaraditya303 commented on Dec 2, 2022

    @kumaraditya303
    kumaraditya303
    on Dec 2, 2022
    Contributor
    More actions

    I am thinking of allowing this rather than documenting this. See my comment #78530 (comment) and let's continue the discussion on that issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    topic-asynciotype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

    Projects

    • asyncio
      Status
      Done
      Show more project fields

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402503 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.