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

gh-119154: Simplify consumers by making `queue.Queue` an iterable by nineteendo · Pull Request #120503 · python/cpython · GitHub

Repository navigation

Closed
Changes from 1 commit
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension .py  (1) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
Prev Previous commit
Next Next commit
Add asyncio.Queue.__iter__()
  • Loading branch information
nineteendo committed Jun 14, 2024
commit c8cbe4d0b1a48d31bfaa2dba3f3874c679a02dbe
7 changes: 7 additions & 0 deletions Lib/asyncio/queues.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,13 @@ def _wakeup_next(self, waiters):
waiter.set_result(None)
break

def __iter__(self):
while True:
try:
yield self.get_nowait()
except (QueueEmpty, QueueShutDown):
return

def __repr__(self):
return f'<{type(self).__name__} at {id(self):#x} {self._format()}>'

Expand Down

Back | FazBrowse Home | New Git URL