Skip to content

Simplify consumers with iteration over *.Queue #120947

Description

@nineteendo

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

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