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

Simplify consumers with iteration over `*.Queue` · Issue #120947 · python/cpython · GitHub

Repository navigation

Simplify consumers with iteration over *.Queue #120947

Closed as not planned
Closed as not planned

Description

Feature or enhancement

Proposal:

Currently consuming items from a queue can be a bit more complex than necessary. You need to

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

By allowing iteration over *.Queue, this becomes a bit easier, you only need to call queue.shutdown().

Has this already been discussed elsewhere?

No response given

Links to previous discussion of this feature:

Linked PRs

Activity

  1. vstinner commented on Jun 24, 2024

    Member

    Please keep discussions about alternatives in an unique issue, rather than opening one issue per alternative. I suggest to close this issue.

  2. nineteendo commented on Jun 24, 2024

    ContributorAuthor

    Huh? That's what this is, it's a single issue to discuss the alternative solutions.

  3. vstinner commented on Jun 24, 2024

    Member

    Huh? That's what this is, it's a single issue to discuss the alternative solutions.

    I'm asking the opposite: discuss your alternative in the existing issue, don't create a new issue just for an alternative.

  4. nineteendo commented on Jun 24, 2024

    ContributorAuthor

    OK, then I misunderstood this comment:

    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