diff --git a/Lib/asyncio/queues.py b/Lib/asyncio/queues.py index a9656a6df561ba..bf8a8f8b5eb08b 100644 --- a/Lib/asyncio/queues.py +++ b/Lib/asyncio/queues.py @@ -128,8 +128,9 @@ async def put(self, item): # previous get_nowait call. pass if not self.full() and not putter.cancelled(): - # We were woken up by get_nowait(), but can't take - # the call. Wake up the next in line. + # We were woken up by get_nowait(), but can't take the + # call. Wake up the next in line. This can happen when + # the putter is set, then the await cancelled. self._wakeup_next(self._putters) raise return self.put_nowait(item) @@ -166,8 +167,9 @@ async def get(self): # previous put_nowait call. pass if not self.empty() and not getter.cancelled(): - # We were woken up by put_nowait(), but can't take - # the call. Wake up the next in line. + # We were woken up by put_nowait(), but can't take the + # call. Wake up the next in line. This can happen when + # the getter is set, then the await cancelled. self._wakeup_next(self._getters) raise return self.get_nowait() diff --git a/Misc/NEWS.d/next/Documentation/2023-09-19-14-55-49.gh-issue-108042.ChCh1e.rst b/Misc/NEWS.d/next/Documentation/2023-09-19-14-55-49.gh-issue-108042.ChCh1e.rst new file mode 100644 index 00000000000000..d4d7278fd98aaa --- /dev/null +++ b/Misc/NEWS.d/next/Documentation/2023-09-19-14-55-49.gh-issue-108042.ChCh1e.rst @@ -0,0 +1 @@ +Improve comments in asyncio.queues.Queue.