Skip to content

Simplify consumers with iteration over *.Queue #120947

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

Closed
nineteendo opened this issue Jun 24, 2024 · 4 comments
Closed

Simplify consumers with iteration over *.Queue #120947

nineteendo opened this issue Jun 24, 2024 · 4 comments
Labels
type-feature A feature request or enhancement

Comments

@nineteendo
Copy link
Contributor

nineteendo commented Jun 24, 2024

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

@vstinner
Copy link
Member

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

@nineteendo
Copy link
Contributor Author

nineteendo commented Jun 24, 2024

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

@vstinner
Copy link
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.

@nineteendo
Copy link
Contributor Author

OK, then I misunderstood this comment:

Please open a single issue to discuss multiple alternatives. I suggest to close this issue.

@nineteendo nineteendo closed this as not planned Won't fix, can't repro, duplicate, stale Jun 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type-feature A feature request or enhancement
Projects
None yet
Development

No branches or pull requests

2 participants