FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Simplify consumers by adding `*.Queue.iter()` and `*.Queue.iter_nowait()` · Issue #120924 · python/cpython · GitHub

Repository navigation

Simplify consumers by adding *.Queue.iter() and *.Queue.iter_nowait() #120924

Closed as not planned

Description

Feature or enhancement

Proposal:

Currently consuming items from a queue is very complex. You need to

  1. use an infinite while loop
  2. call queue.task_done() after processing each item
  3. add all worker tasks to a list
  4. join the queue
  5. cancel all worker tasks.
  6. wait until all worker tasks are cancelled

By adding asyncio.Queue.iter() and asyncio.Queue.iter_nowait(), this becomes a lot easier, you only need to call queue.shutdown(). The same applies to synchronous queues.

Has this already been discussed elsewhere?

No response given

Links to previous discussion of this feature:

Linked PRs

Activity

  1. nineteendo commented on Jun 23, 2024

    ContributorAuthor

    This is an alternative to #120499 and #119154.

  2. added a commit that references this issue on Jun 24, 2024
  3. vstinner commented on Jun 24, 2024

    Member

    This is an alternative to #120499 and #119154.

    Please open a single issue to discuss multiple alternatives. I suggest to close this 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

    type-featureA feature request or enhancement

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions


      Back | FazBrowse Home | New Git URL