-
-
Notifications
You must be signed in to change notification settings - Fork 34.4k
Simplify consumers by making queue.Queue an iterable #120499
Copy link
Copy link
Closed as not planned
Labels
type-featureA feature request or enhancementA feature request or enhancement
Description
Feature or enhancement
Proposal:
class Iterator:
def __init__(self, queue):
self.queue = queue
def __iter__(self):
return self
async def __next__(self):
try:
return self.queue.get_nowait()
except (Empty, ShutDown):
raise StopIteration
class Queue:
...
def __iter__(self):
return Iterator(self)Has this already been discussed elsewhere?
This is a minor feature, which does not need previous discussion elsewhere
Links to previous discussion of this feature:
Linked PRs
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
type-featureA feature request or enhancementA feature request or enhancement