From e9c1a3e381f5d919d837eba9ade321719d679f18 Mon Sep 17 00:00:00 2001 From: Nineteendo Date: Fri, 14 Jun 2024 11:31:55 +0200 Subject: [PATCH 01/42] Add `asyncio.Queue.__aiter__()` Co-authored-by: Guido van Rossum --- Lib/asyncio/queues.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/Lib/asyncio/queues.py b/Lib/asyncio/queues.py index 2f3865114a84f9..9bc07e1e0f70dc 100644 --- a/Lib/asyncio/queues.py +++ b/Lib/asyncio/queues.py @@ -30,6 +30,22 @@ class QueueShutDown(Exception): pass +class AsyncQueueIterator: + def __init__(self, queue): + self.queue = queue + + def __aiter__(self): + return self + + async def __anext__(self): + try: + item = await self.queue.get() + except QueueShutDown: + raise StopAsyncIteration + else: + return item + + class Queue(mixins._LoopBoundMixin): """A queue, useful for coordinating producer and consumer coroutines. @@ -76,6 +92,9 @@ def _wakeup_next(self, waiters): waiter.set_result(None) break + def __aiter__(self): + return AsyncQueueIterator(self) + def __repr__(self): return f'<{type(self).__name__} at {id(self):#x} {self._format()}>' @@ -200,6 +219,7 @@ async def get(self): raise return self.get_nowait() + def get_nowait(self): """Remove and return an item from the queue. From 3cd59ee95949448cef6e9adb68897c4788390ed5 Mon Sep 17 00:00:00 2001 From: Nineteendo Date: Fri, 14 Jun 2024 11:47:40 +0200 Subject: [PATCH 02/42] Reduce diff --- Lib/asyncio/queues.py | 1 - 1 file changed, 1 deletion(-) diff --git a/Lib/asyncio/queues.py b/Lib/asyncio/queues.py index 9bc07e1e0f70dc..393a08c2135fa7 100644 --- a/Lib/asyncio/queues.py +++ b/Lib/asyncio/queues.py @@ -219,7 +219,6 @@ async def get(self): raise return self.get_nowait() - def get_nowait(self): """Remove and return an item from the queue. From 16fc429f43738f546db8b94613c5b48f8e0c3cda Mon Sep 17 00:00:00 2001 From: Nineteendo Date: Fri, 14 Jun 2024 12:18:57 +0200 Subject: [PATCH 03/42] Add test --- Lib/test/test_asyncio/test_queues.py | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/Lib/test/test_asyncio/test_queues.py b/Lib/test/test_asyncio/test_queues.py index 5019e9a293525d..3da6c0c0f8c137 100644 --- a/Lib/test/test_asyncio/test_queues.py +++ b/Lib/test/test_asyncio/test_queues.py @@ -471,27 +471,23 @@ async def test_task_done(self): # Two workers get items from the queue and call task_done after each. # Join the queue and assert all items have been processed. - running = True async def worker(): nonlocal accumulator - while running: - item = await q.get() + async for item in q: accumulator += item q.task_done() async with asyncio.TaskGroup() as tg: - tasks = [tg.create_task(worker()) - for index in range(2)] + for _ in range(2): + tg.create_task(worker()) await q.join() self.assertEqual(sum(range(100)), accumulator) # close running generators - running = False - for i in range(len(tasks)): - q.put_nowait(0) + q.shutdown() async def test_join_empty_queue(self): q = self.q_class() From f13ddb3912e1e6efbf613f80ea7b51993a86f246 Mon Sep 17 00:00:00 2001 From: Nineteendo Date: Fri, 14 Jun 2024 12:24:04 +0200 Subject: [PATCH 04/42] Simplify code --- Lib/asyncio/queues.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Lib/asyncio/queues.py b/Lib/asyncio/queues.py index 393a08c2135fa7..c82147da02ac72 100644 --- a/Lib/asyncio/queues.py +++ b/Lib/asyncio/queues.py @@ -39,11 +39,9 @@ def __aiter__(self): async def __anext__(self): try: - item = await self.queue.get() + return await self.queue.get() except QueueShutDown: raise StopAsyncIteration - else: - return item class Queue(mixins._LoopBoundMixin): From afd7ad4a0ea2d3535946ba775d3fc2cb0cf04629 Mon Sep 17 00:00:00 2001 From: Nineteendo Date: Fri, 14 Jun 2024 12:26:00 +0200 Subject: [PATCH 05/42] Add to `__all__` --- Lib/asyncio/queues.py | 1 + 1 file changed, 1 insertion(+) diff --git a/Lib/asyncio/queues.py b/Lib/asyncio/queues.py index c82147da02ac72..33abb84b8cce0d 100644 --- a/Lib/asyncio/queues.py +++ b/Lib/asyncio/queues.py @@ -5,6 +5,7 @@ 'QueueFull', 'QueueEmpty', 'QueueShutDown', + 'AsyncQueueIterator', ) import collections From 214548c4b2a774b0fef2098ec59a51d7337fbccc Mon Sep 17 00:00:00 2001 From: "blurb-it[bot]" <43283697+blurb-it[bot]@users.noreply.github.com> Date: Fri, 14 Jun 2024 10:30:44 +0000 Subject: [PATCH 06/42] =?UTF-8?q?=F0=9F=93=9C=F0=9F=A4=96=20Added=20by=20b?= =?UTF-8?q?lurb=5Fit.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../2024-06-14-10-30-43.gh-issue-119154.1MHWA-.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 Misc/NEWS.d/next/Core and Builtins/2024-06-14-10-30-43.gh-issue-119154.1MHWA-.rst diff --git a/Misc/NEWS.d/next/Core and Builtins/2024-06-14-10-30-43.gh-issue-119154.1MHWA-.rst b/Misc/NEWS.d/next/Core and Builtins/2024-06-14-10-30-43.gh-issue-119154.1MHWA-.rst new file mode 100644 index 00000000000000..21d2f98fb6b622 --- /dev/null +++ b/Misc/NEWS.d/next/Core and Builtins/2024-06-14-10-30-43.gh-issue-119154.1MHWA-.rst @@ -0,0 +1 @@ +Make :class:`asyncio.Queue` an asynchronous iterable. From 9824b639a8b001db0f3b94e2a2319dc32f2d5110 Mon Sep 17 00:00:00 2001 From: Nineteendo Date: Fri, 14 Jun 2024 12:50:10 +0200 Subject: [PATCH 07/42] Simplify example --- Doc/library/asyncio-queue.rst | 72 ++++++++++++++++------------------- 1 file changed, 32 insertions(+), 40 deletions(-) diff --git a/Doc/library/asyncio-queue.rst b/Doc/library/asyncio-queue.rst index 9b579cc1d5fdfe..2f403f0457ec59 100644 --- a/Doc/library/asyncio-queue.rst +++ b/Doc/library/asyncio-queue.rst @@ -191,50 +191,42 @@ concurrent tasks:: async def worker(name, queue): - while True: - # Get a "work item" out of the queue. - sleep_for = await queue.get() + # Get a "work item" out of the queue. + async for sleep_for in queue: + # Sleep for the "sleep_for" seconds. + await asyncio.sleep(sleep_for) - # Sleep for the "sleep_for" seconds. - await asyncio.sleep(sleep_for) - - # Notify the queue that the "work item" has been processed. - queue.task_done() - - print(f'{name} has slept for {sleep_for:.2f} seconds') + print(f'{name} has slept for {sleep_for:.2f} seconds') async def main(): - # Create a queue that we will use to store our "workload". - queue = asyncio.Queue() - - # Generate random timings and put them into the queue. - total_sleep_time = 0 - for _ in range(20): - sleep_for = random.uniform(0.05, 1.0) - total_sleep_time += sleep_for - queue.put_nowait(sleep_for) - - # Create three worker tasks to process the queue concurrently. - tasks = [] - for i in range(3): - task = asyncio.create_task(worker(f'worker-{i}', queue)) - tasks.append(task) - - # Wait until the queue is fully processed. - started_at = time.monotonic() - await queue.join() - total_slept_for = time.monotonic() - started_at - - # Cancel our worker tasks. - for task in tasks: - task.cancel() - # Wait until all worker tasks are cancelled. - await asyncio.gather(*tasks, return_exceptions=True) - - print('====') - print(f'3 workers slept in parallel for {total_slept_for:.2f} seconds') - print(f'total expected sleep time: {total_sleep_time:.2f} seconds') + # Create a queue that we will use to store our "workload". + queue = asyncio.Queue() + + # Generate random timings and put them into the queue. + total_sleep_time = 0 + for _ in range(20): + sleep_for = random.uniform(0.05, 1.0) + total_sleep_time += sleep_for + queue.put_nowait(sleep_for) + + # All tasks have been queued + queue.shutdown() + + # Create three worker tasks to process the queue concurrently. + tasks = [] + for i in range(3): + task = asyncio.create_task(worker(f'worker-{i}', queue)) + tasks.append(task) + + # Wait until the queue is fully processed. + started_at = time.monotonic() + await asyncio.gather(*tasks, return_exceptions=True) + total_slept_for = time.monotonic() - started_at + + print('====') + print(f'3 workers slept in parallel for {total_slept_for:.2f} seconds') + print(f'total expected sleep time: {total_sleep_time:.2f} seconds') asyncio.run(main()) From 6358b8ec6bc4b8665b3a47a8a48cfdfe2b8875c6 Mon Sep 17 00:00:00 2001 From: Nineteendo Date: Fri, 14 Jun 2024 12:57:49 +0200 Subject: [PATCH 08/42] Fix indentation --- Doc/library/asyncio-queue.rst | 64 +++++++++++++++++------------------ 1 file changed, 32 insertions(+), 32 deletions(-) diff --git a/Doc/library/asyncio-queue.rst b/Doc/library/asyncio-queue.rst index 2f403f0457ec59..ec27bbf2c80ef7 100644 --- a/Doc/library/asyncio-queue.rst +++ b/Doc/library/asyncio-queue.rst @@ -191,42 +191,42 @@ concurrent tasks:: async def worker(name, queue): - # Get a "work item" out of the queue. - async for sleep_for in queue: - # Sleep for the "sleep_for" seconds. - await asyncio.sleep(sleep_for) + # Get a "work item" out of the queue. + async for sleep_for in queue: + # Sleep for the "sleep_for" seconds. + await asyncio.sleep(sleep_for) - print(f'{name} has slept for {sleep_for:.2f} seconds') + print(f'{name} has slept for {sleep_for:.2f} seconds') async def main(): - # Create a queue that we will use to store our "workload". - queue = asyncio.Queue() - - # Generate random timings and put them into the queue. - total_sleep_time = 0 - for _ in range(20): - sleep_for = random.uniform(0.05, 1.0) - total_sleep_time += sleep_for - queue.put_nowait(sleep_for) - - # All tasks have been queued - queue.shutdown() - - # Create three worker tasks to process the queue concurrently. - tasks = [] - for i in range(3): - task = asyncio.create_task(worker(f'worker-{i}', queue)) - tasks.append(task) - - # Wait until the queue is fully processed. - started_at = time.monotonic() - await asyncio.gather(*tasks, return_exceptions=True) - total_slept_for = time.monotonic() - started_at - - print('====') - print(f'3 workers slept in parallel for {total_slept_for:.2f} seconds') - print(f'total expected sleep time: {total_sleep_time:.2f} seconds') + # Create a queue that we will use to store our "workload". + queue = asyncio.Queue() + + # Generate random timings and put them into the queue. + total_sleep_time = 0 + for _ in range(20): + sleep_for = random.uniform(0.05, 1.0) + total_sleep_time += sleep_for + queue.put_nowait(sleep_for) + + # All tasks have been queued + queue.shutdown() + + # Create three worker tasks to process the queue concurrently. + tasks = [] + for i in range(3): + task = asyncio.create_task(worker(f'worker-{i}', queue)) + tasks.append(task) + + # Wait until the queue is fully processed. + started_at = time.monotonic() + await asyncio.gather(*tasks, return_exceptions=True) + total_slept_for = time.monotonic() - started_at + + print('====') + print(f'3 workers slept in parallel for {total_slept_for:.2f} seconds') + print(f'total expected sleep time: {total_sleep_time:.2f} seconds') asyncio.run(main()) From 316b8006ef5c675a65758c660e00b700e654138a Mon Sep 17 00:00:00 2001 From: Nineteendo Date: Fri, 14 Jun 2024 13:11:22 +0200 Subject: [PATCH 09/42] Improve order --- Lib/test/test_asyncio/test_queues.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Lib/test/test_asyncio/test_queues.py b/Lib/test/test_asyncio/test_queues.py index 3da6c0c0f8c137..859f746d791b35 100644 --- a/Lib/test/test_asyncio/test_queues.py +++ b/Lib/test/test_asyncio/test_queues.py @@ -467,6 +467,9 @@ async def test_task_done(self): for i in range(100): q.put_nowait(i) + # All tasks have been queued + q.shutdown() + accumulator = 0 # Two workers get items from the queue and call task_done after each. @@ -486,9 +489,6 @@ async def worker(): await q.join() self.assertEqual(sum(range(100)), accumulator) - # close running generators - q.shutdown() - async def test_join_empty_queue(self): q = self.q_class() From 92f32954db74d624f37306d427b6d710b588dc42 Mon Sep 17 00:00:00 2001 From: Nineteendo Date: Fri, 14 Jun 2024 13:21:45 +0200 Subject: [PATCH 10/42] Test `StopAsyncIteration` --- Lib/test/test_asyncio/test_queues.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/Lib/test/test_asyncio/test_queues.py b/Lib/test/test_asyncio/test_queues.py index 859f746d791b35..6e230d649cd361 100644 --- a/Lib/test/test_asyncio/test_queues.py +++ b/Lib/test/test_asyncio/test_queues.py @@ -116,6 +116,30 @@ async def putter(): self.assertTrue(t.done()) self.assertTrue(t.result()) + async def test_aiter(self): + q = asyncio.Queue() + for i in range(100): + q.put_nowait(i) + + # All tasks have been queued + q.shutdown() + + accumulator = 0 + + # Two workers get items from the queue and call task_done after each. + # Join the queue and assert all items have been processed. + + async def worker(): + nonlocal accumulator + + async for item in q: + accumulator += item + + async with asyncio.TaskGroup() as tg: + tasks = [tg.create_task(worker()) for _ in range(2)] + await asyncio.gather(*tasks, return_exceptions=True) + self.assertEqual(sum(range(100)), accumulator) + class QueueGetTests(unittest.IsolatedAsyncioTestCase): From a18767df829a4f65fe921a3a043c44810f5dbbd2 Mon Sep 17 00:00:00 2001 From: Nineteendo Date: Fri, 14 Jun 2024 13:28:47 +0200 Subject: [PATCH 11/42] Document `AsyncQueueIterator` --- Doc/library/asyncio-queue.rst | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/Doc/library/asyncio-queue.rst b/Doc/library/asyncio-queue.rst index ec27bbf2c80ef7..dece95247dc342 100644 --- a/Doc/library/asyncio-queue.rst +++ b/Doc/library/asyncio-queue.rst @@ -133,6 +133,21 @@ Queue items placed in the queue. +Async Queue Iterator +==================== + +.. class:: AsyncQueueIterator(queue) + + The :term:`asynchronous iterator` returned by calling :func:`aiter` + on a :class:`Queue`. + +.. attribute:: queue + + The queue backed by the ``AsyncQueueIterator``. + +.. versionadded:: 3.14 + + Priority Queue ============== From 320691cd422e5a3f0c323985d5db399a524badcf Mon Sep 17 00:00:00 2001 From: Nice Zombies Date: Sat, 15 Jun 2024 06:36:54 +0200 Subject: [PATCH 12/42] Apply suggestions from code review Co-authored-by: Zac Hatfield-Dodds --- Doc/library/asyncio-queue.rst | 2 +- Lib/test/test_asyncio/test_queues.py | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Doc/library/asyncio-queue.rst b/Doc/library/asyncio-queue.rst index dece95247dc342..3fbbdf8a8e4251 100644 --- a/Doc/library/asyncio-queue.rst +++ b/Doc/library/asyncio-queue.rst @@ -143,7 +143,7 @@ Async Queue Iterator .. attribute:: queue - The queue backed by the ``AsyncQueueIterator``. + The queue which backs this ``AsyncQueueIterator``. .. versionadded:: 3.14 diff --git a/Lib/test/test_asyncio/test_queues.py b/Lib/test/test_asyncio/test_queues.py index 6e230d649cd361..ca9a92b8e79e54 100644 --- a/Lib/test/test_asyncio/test_queues.py +++ b/Lib/test/test_asyncio/test_queues.py @@ -136,9 +136,9 @@ async def worker(): accumulator += item async with asyncio.TaskGroup() as tg: - tasks = [tg.create_task(worker()) for _ in range(2)] - await asyncio.gather(*tasks, return_exceptions=True) - self.assertEqual(sum(range(100)), accumulator) + tg.create_task(worker()) + tg.create_task(worker()) + self.assertEqual(sum(range(100)), accumulator) class QueueGetTests(unittest.IsolatedAsyncioTestCase): From f43bdb17235fee0bdf6680854d01affba49d0ac5 Mon Sep 17 00:00:00 2001 From: Nineteendo Date: Sat, 15 Jun 2024 06:47:18 +0200 Subject: [PATCH 13/42] Unpack for loop --- Lib/test/test_asyncio/test_queues.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Lib/test/test_asyncio/test_queues.py b/Lib/test/test_asyncio/test_queues.py index ca9a92b8e79e54..9211ecefba6dd9 100644 --- a/Lib/test/test_asyncio/test_queues.py +++ b/Lib/test/test_asyncio/test_queues.py @@ -507,9 +507,8 @@ async def worker(): q.task_done() async with asyncio.TaskGroup() as tg: - for _ in range(2): - tg.create_task(worker()) - + tg.create_task(worker()) + tg.create_task(worker()) await q.join() self.assertEqual(sum(range(100)), accumulator) From 4ca4a93e18a239521da1a359bd8af6e9020a873c Mon Sep 17 00:00:00 2001 From: Nineteendo Date: Sat, 15 Jun 2024 06:48:44 +0200 Subject: [PATCH 14/42] Insert newline --- Lib/test/test_asyncio/test_queues.py | 1 + 1 file changed, 1 insertion(+) diff --git a/Lib/test/test_asyncio/test_queues.py b/Lib/test/test_asyncio/test_queues.py index 9211ecefba6dd9..4f9abcd0b6a973 100644 --- a/Lib/test/test_asyncio/test_queues.py +++ b/Lib/test/test_asyncio/test_queues.py @@ -138,6 +138,7 @@ async def worker(): async with asyncio.TaskGroup() as tg: tg.create_task(worker()) tg.create_task(worker()) + self.assertEqual(sum(range(100)), accumulator) From fffacb2cbfd5ca588bfa348068ca101edd628925 Mon Sep 17 00:00:00 2001 From: Nineteendo Date: Sat, 15 Jun 2024 07:00:22 +0200 Subject: [PATCH 15/42] Simplify example --- Doc/library/asyncio-queue.rst | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/Doc/library/asyncio-queue.rst b/Doc/library/asyncio-queue.rst index 3fbbdf8a8e4251..047c45a533ec14 100644 --- a/Doc/library/asyncio-queue.rst +++ b/Doc/library/asyncio-queue.rst @@ -229,14 +229,11 @@ concurrent tasks:: queue.shutdown() # Create three worker tasks to process the queue concurrently. - tasks = [] - for i in range(3): - task = asyncio.create_task(worker(f'worker-{i}', queue)) - tasks.append(task) - - # Wait until the queue is fully processed. started_at = time.monotonic() - await asyncio.gather(*tasks, return_exceptions=True) + async with asyncio.TaskGroup() as tg: + for i in range(3): + tg.create_task(worker(f'worker-{i}', queue)) + total_slept_for = time.monotonic() - started_at print('====') From 92d7b16d0f511b49e40a709a4144d2b416572db7 Mon Sep 17 00:00:00 2001 From: Nineteendo Date: Sat, 15 Jun 2024 07:03:16 +0200 Subject: [PATCH 16/42] Indent correctly --- Doc/library/asyncio-queue.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Doc/library/asyncio-queue.rst b/Doc/library/asyncio-queue.rst index 047c45a533ec14..1a5926183da0c2 100644 --- a/Doc/library/asyncio-queue.rst +++ b/Doc/library/asyncio-queue.rst @@ -141,11 +141,11 @@ Async Queue Iterator The :term:`asynchronous iterator` returned by calling :func:`aiter` on a :class:`Queue`. -.. attribute:: queue + .. versionadded:: 3.14 - The queue which backs this ``AsyncQueueIterator``. + .. attribute:: queue -.. versionadded:: 3.14 + The queue which backs this ``AsyncQueueIterator``. Priority Queue From ce23fcedf1bb3686ed85ab4f9b10e0337ca88409 Mon Sep 17 00:00:00 2001 From: Nineteendo Date: Sat, 15 Jun 2024 07:29:52 +0200 Subject: [PATCH 17/42] Document `__aiter__()` --- Doc/library/asyncio-queue.rst | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Doc/library/asyncio-queue.rst b/Doc/library/asyncio-queue.rst index 1a5926183da0c2..6a11cabde809cd 100644 --- a/Doc/library/asyncio-queue.rst +++ b/Doc/library/asyncio-queue.rst @@ -46,6 +46,18 @@ Queue Number of items allowed in the queue. + .. method:: __aiter__() + Return an :class:`AsyncQueueIterator` which iterates asynchronously + over the items in this queue until :meth:`shutdown` is called and + the queue is empty:: + + ... # add items to the queue + queue.shutdown() + async for item in queue: + ... # process item + + .. versionadded:: 3.14 + .. method:: empty() Return ``True`` if the queue is empty, ``False`` otherwise. From 640d2a8a59f7385ccd806462cf2a255df032311f Mon Sep 17 00:00:00 2001 From: Nineteendo Date: Sat, 15 Jun 2024 07:34:58 +0200 Subject: [PATCH 18/42] Fix indent attempt 1 --- Doc/library/asyncio-queue.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/Doc/library/asyncio-queue.rst b/Doc/library/asyncio-queue.rst index 6a11cabde809cd..57e73984a25982 100644 --- a/Doc/library/asyncio-queue.rst +++ b/Doc/library/asyncio-queue.rst @@ -47,6 +47,7 @@ Queue Number of items allowed in the queue. .. method:: __aiter__() + Return an :class:`AsyncQueueIterator` which iterates asynchronously over the items in this queue until :meth:`shutdown` is called and the queue is empty:: From 6c9aa6d6e7ec3668e3b12c4869ec7bac063e6c9d Mon Sep 17 00:00:00 2001 From: Nineteendo Date: Tue, 18 Jun 2024 20:07:07 +0200 Subject: [PATCH 19/42] Make `AsyncQueueIterator` private --- Doc/library/asyncio-queue.rst | 26 +++----------------------- Lib/asyncio/queues.py | 5 ++--- 2 files changed, 5 insertions(+), 26 deletions(-) diff --git a/Doc/library/asyncio-queue.rst b/Doc/library/asyncio-queue.rst index 57e73984a25982..8dfa3f56d080d2 100644 --- a/Doc/library/asyncio-queue.rst +++ b/Doc/library/asyncio-queue.rst @@ -48,14 +48,9 @@ Queue .. method:: __aiter__() - Return an :class:`AsyncQueueIterator` which iterates asynchronously - over the items in this queue until :meth:`shutdown` is called and - the queue is empty:: - - ... # add items to the queue - queue.shutdown() - async for item in queue: - ... # process item + Return an iterator which iterates asynchronously over the items + in this queue until :meth:`shutdown` is called and the queue is + empty. .. versionadded:: 3.14 @@ -146,21 +141,6 @@ Queue items placed in the queue. -Async Queue Iterator -==================== - -.. class:: AsyncQueueIterator(queue) - - The :term:`asynchronous iterator` returned by calling :func:`aiter` - on a :class:`Queue`. - - .. versionadded:: 3.14 - - .. attribute:: queue - - The queue which backs this ``AsyncQueueIterator``. - - Priority Queue ============== diff --git a/Lib/asyncio/queues.py b/Lib/asyncio/queues.py index 33abb84b8cce0d..9d5d5c453132e0 100644 --- a/Lib/asyncio/queues.py +++ b/Lib/asyncio/queues.py @@ -5,7 +5,6 @@ 'QueueFull', 'QueueEmpty', 'QueueShutDown', - 'AsyncQueueIterator', ) import collections @@ -31,7 +30,7 @@ class QueueShutDown(Exception): pass -class AsyncQueueIterator: +class _AsyncQueueIterator: def __init__(self, queue): self.queue = queue @@ -92,7 +91,7 @@ def _wakeup_next(self, waiters): break def __aiter__(self): - return AsyncQueueIterator(self) + return _AsyncQueueIterator(self) def __repr__(self): return f'<{type(self).__name__} at {id(self):#x} {self._format()}>' From e6a5849ac8db0269c27e5d36717b1c339340491e Mon Sep 17 00:00:00 2001 From: Nineteendo Date: Tue, 18 Jun 2024 20:50:33 +0200 Subject: [PATCH 20/42] Use term --- Doc/library/asyncio-queue.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Doc/library/asyncio-queue.rst b/Doc/library/asyncio-queue.rst index 8dfa3f56d080d2..6d50db026a0520 100644 --- a/Doc/library/asyncio-queue.rst +++ b/Doc/library/asyncio-queue.rst @@ -48,9 +48,9 @@ Queue .. method:: __aiter__() - Return an iterator which iterates asynchronously over the items - in this queue until :meth:`shutdown` is called and the queue is - empty. + Return an :term:`iterator` which iterates asynchronously over + the items in this queue until :meth:`shutdown` is called and + the queue is empty. .. versionadded:: 3.14 From 583f642bb2d5044c863d77cdaf6c9568e372bb3d Mon Sep 17 00:00:00 2001 From: Nineteendo Date: Tue, 18 Jun 2024 21:15:12 +0200 Subject: [PATCH 21/42] Re-order --- Lib/test/test_asyncio/test_queues.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Lib/test/test_asyncio/test_queues.py b/Lib/test/test_asyncio/test_queues.py index 4f9abcd0b6a973..082bd08237f670 100644 --- a/Lib/test/test_asyncio/test_queues.py +++ b/Lib/test/test_asyncio/test_queues.py @@ -492,9 +492,6 @@ async def test_task_done(self): for i in range(100): q.put_nowait(i) - # All tasks have been queued - q.shutdown() - accumulator = 0 # Two workers get items from the queue and call task_done after each. @@ -513,6 +510,9 @@ async def worker(): await q.join() self.assertEqual(sum(range(100)), accumulator) + # close running generators + q.shutdown() + async def test_join_empty_queue(self): q = self.q_class() From 1b6e78135503dfa4feafc83bf4f728d853286993 Mon Sep 17 00:00:00 2001 From: Nineteendo Date: Tue, 18 Jun 2024 21:18:29 +0200 Subject: [PATCH 22/42] Remove comment --- Lib/test/test_asyncio/test_queues.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/Lib/test/test_asyncio/test_queues.py b/Lib/test/test_asyncio/test_queues.py index 082bd08237f670..c5f8e4b36141d1 100644 --- a/Lib/test/test_asyncio/test_queues.py +++ b/Lib/test/test_asyncio/test_queues.py @@ -126,9 +126,6 @@ async def test_aiter(self): accumulator = 0 - # Two workers get items from the queue and call task_done after each. - # Join the queue and assert all items have been processed. - async def worker(): nonlocal accumulator From 2d5998ada601b06a84158b16ee0e4db56b72f477 Mon Sep 17 00:00:00 2001 From: Nice Zombies Date: Wed, 19 Jun 2024 12:03:54 +0200 Subject: [PATCH 23/42] Update whatsnew --- Doc/whatsnew/3.14.rst | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Doc/whatsnew/3.14.rst b/Doc/whatsnew/3.14.rst index b357553735e8bb..4c058c3a029c29 100644 --- a/Doc/whatsnew/3.14.rst +++ b/Doc/whatsnew/3.14.rst @@ -92,6 +92,12 @@ ast Added :func:`ast.compare` for comparing two ASTs. (Contributed by Batuhan Taskaya and Jeremy Hylton in :issue:`15987`.) +asyncio +------- + +Made :class:`asyncio.Queue` an asynchronous iterable. +(Contributed by Wannes Boeykens in :gh:`120491`.) + os -- From 841d50c8dbfa49117f5d90fa4e0b0a67ffff7588 Mon Sep 17 00:00:00 2001 From: Nice Zombies Date: Wed, 19 Jun 2024 12:04:28 +0200 Subject: [PATCH 24/42] Update blurb --- .../2024-06-14-10-30-43.gh-issue-119154.1MHWA-.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/Misc/NEWS.d/next/Core and Builtins/2024-06-14-10-30-43.gh-issue-119154.1MHWA-.rst b/Misc/NEWS.d/next/Core and Builtins/2024-06-14-10-30-43.gh-issue-119154.1MHWA-.rst index 21d2f98fb6b622..7c1110b60fc273 100644 --- a/Misc/NEWS.d/next/Core and Builtins/2024-06-14-10-30-43.gh-issue-119154.1MHWA-.rst +++ b/Misc/NEWS.d/next/Core and Builtins/2024-06-14-10-30-43.gh-issue-119154.1MHWA-.rst @@ -1 +1,2 @@ Make :class:`asyncio.Queue` an asynchronous iterable. +(Contributed by Wannes Boeykens in :gh:`120491`.) From d624beaa4925d99a30900df2ac7a705876c324a3 Mon Sep 17 00:00:00 2001 From: Nice Zombies Date: Wed, 19 Jun 2024 12:12:04 +0200 Subject: [PATCH 25/42] Apply suggestions from code review --- Doc/whatsnew/3.14.rst | 2 +- .../2024-06-14-10-30-43.gh-issue-119154.1MHWA-.rst | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Doc/whatsnew/3.14.rst b/Doc/whatsnew/3.14.rst index 4c058c3a029c29..c7f4db10c9fafc 100644 --- a/Doc/whatsnew/3.14.rst +++ b/Doc/whatsnew/3.14.rst @@ -95,7 +95,7 @@ Added :func:`ast.compare` for comparing two ASTs. asyncio ------- -Made :class:`asyncio.Queue` an asynchronous iterable. +Made :class:`asyncio.Queue` an :term:`asynchronous iterable`. (Contributed by Wannes Boeykens in :gh:`120491`.) os diff --git a/Misc/NEWS.d/next/Core and Builtins/2024-06-14-10-30-43.gh-issue-119154.1MHWA-.rst b/Misc/NEWS.d/next/Core and Builtins/2024-06-14-10-30-43.gh-issue-119154.1MHWA-.rst index 7c1110b60fc273..38bd9c61c33422 100644 --- a/Misc/NEWS.d/next/Core and Builtins/2024-06-14-10-30-43.gh-issue-119154.1MHWA-.rst +++ b/Misc/NEWS.d/next/Core and Builtins/2024-06-14-10-30-43.gh-issue-119154.1MHWA-.rst @@ -1,2 +1,2 @@ -Make :class:`asyncio.Queue` an asynchronous iterable. +Make :class:`asyncio.Queue` an :term:`asynchronous iterable`. (Contributed by Wannes Boeykens in :gh:`120491`.) From 0a8a72b59b42abc67c8084053bf3e4cf2259bbb7 Mon Sep 17 00:00:00 2001 From: Nice Zombies Date: Wed, 19 Jun 2024 12:13:21 +0200 Subject: [PATCH 26/42] Update Doc/library/asyncio-queue.rst --- Doc/library/asyncio-queue.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/library/asyncio-queue.rst b/Doc/library/asyncio-queue.rst index 6d50db026a0520..1fc9797135d389 100644 --- a/Doc/library/asyncio-queue.rst +++ b/Doc/library/asyncio-queue.rst @@ -48,7 +48,7 @@ Queue .. method:: __aiter__() - Return an :term:`iterator` which iterates asynchronously over + Return an :term:`asynchronous iterator` which iterates over the items in this queue until :meth:`shutdown` is called and the queue is empty. From b3199dfad4fdc8d5ea6383e7d61145011a885ced Mon Sep 17 00:00:00 2001 From: Nice Zombies Date: Wed, 19 Jun 2024 12:33:28 +0200 Subject: [PATCH 27/42] Rename 2024-06-14-10-30-43.gh-issue-119154.1MHWA-.rst to 2024-06-14-10-30-43.gh-issue-119154.1MHWA-.rst --- .../2024-06-14-10-30-43.gh-issue-119154.1MHWA-.rst | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename Misc/NEWS.d/next/{Core and Builtins => Library}/2024-06-14-10-30-43.gh-issue-119154.1MHWA-.rst (100%) diff --git a/Misc/NEWS.d/next/Core and Builtins/2024-06-14-10-30-43.gh-issue-119154.1MHWA-.rst b/Misc/NEWS.d/next/Library/2024-06-14-10-30-43.gh-issue-119154.1MHWA-.rst similarity index 100% rename from Misc/NEWS.d/next/Core and Builtins/2024-06-14-10-30-43.gh-issue-119154.1MHWA-.rst rename to Misc/NEWS.d/next/Library/2024-06-14-10-30-43.gh-issue-119154.1MHWA-.rst From d71eb91e9474111af26dc8f3e4dce94ba1be8c31 Mon Sep 17 00:00:00 2001 From: Nice Zombies Date: Wed, 19 Jun 2024 12:35:17 +0200 Subject: [PATCH 28/42] Make queue a private attribute Co-authored-by: Kumar Aditya --- Lib/asyncio/queues.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Lib/asyncio/queues.py b/Lib/asyncio/queues.py index 9d5d5c453132e0..f799efa0534c40 100644 --- a/Lib/asyncio/queues.py +++ b/Lib/asyncio/queues.py @@ -32,14 +32,14 @@ class QueueShutDown(Exception): class _AsyncQueueIterator: def __init__(self, queue): - self.queue = queue + self._queue = queue def __aiter__(self): return self async def __anext__(self): try: - return await self.queue.get() + return await self._queue.get() except QueueShutDown: raise StopAsyncIteration From 23e37f4e7b47779920ae8222f4554442ea669df2 Mon Sep 17 00:00:00 2001 From: Nice Zombies Date: Thu, 20 Jun 2024 08:03:11 +0200 Subject: [PATCH 29/42] Clarify behaviour --- Doc/library/asyncio-queue.rst | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Doc/library/asyncio-queue.rst b/Doc/library/asyncio-queue.rst index 1fc9797135d389..eb55e8258292c5 100644 --- a/Doc/library/asyncio-queue.rst +++ b/Doc/library/asyncio-queue.rst @@ -49,8 +49,10 @@ Queue .. method:: __aiter__() Return an :term:`asynchronous iterator` which iterates over - the items in this queue until :meth:`shutdown` is called and - the queue is empty. + the queue of items until :meth:`shutdown` is called continues + iteration until the queue is empty. + + ``shutdown(immediate=True)`` stops iteration immediately. .. versionadded:: 3.14 From 3bb4e6585c0b8a27d521cfbfce37d936a5176718 Mon Sep 17 00:00:00 2001 From: Nice Zombies Date: Thu, 20 Jun 2024 08:04:13 +0200 Subject: [PATCH 30/42] Fix grammar --- Doc/library/asyncio-queue.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Doc/library/asyncio-queue.rst b/Doc/library/asyncio-queue.rst index eb55e8258292c5..62c7bac734bd4a 100644 --- a/Doc/library/asyncio-queue.rst +++ b/Doc/library/asyncio-queue.rst @@ -49,8 +49,8 @@ Queue .. method:: __aiter__() Return an :term:`asynchronous iterator` which iterates over - the queue of items until :meth:`shutdown` is called continues - iteration until the queue is empty. + the queue of items until :meth:`shutdown` is called and + continues iteration until the queue is empty. ``shutdown(immediate=True)`` stops iteration immediately. From ba8b13416e9f089b27feffdf311c53165cbda4f7 Mon Sep 17 00:00:00 2001 From: Nineteendo Date: Sun, 23 Jun 2024 21:54:54 +0200 Subject: [PATCH 31/42] Explicit method --- Doc/library/asyncio-queue.rst | 24 +++++++++++---------- Lib/asyncio/queues.py | 19 +++++++++++++++-- Lib/test/test_asyncio/test_queues.py | 31 +++++++++++++++++++++------- 3 files changed, 54 insertions(+), 20 deletions(-) diff --git a/Doc/library/asyncio-queue.rst b/Doc/library/asyncio-queue.rst index 62c7bac734bd4a..9f2eb1053f2eb3 100644 --- a/Doc/library/asyncio-queue.rst +++ b/Doc/library/asyncio-queue.rst @@ -46,16 +46,6 @@ Queue Number of items allowed in the queue. - .. method:: __aiter__() - - Return an :term:`asynchronous iterator` which iterates over - the queue of items until :meth:`shutdown` is called and - continues iteration until the queue is empty. - - ``shutdown(immediate=True)`` stops iteration immediately. - - .. versionadded:: 3.14 - .. method:: empty() Return ``True`` if the queue is empty, ``False`` otherwise. @@ -80,6 +70,18 @@ Queue Return an item if one is immediately available, else raise :exc:`QueueEmpty`. + .. method:: iter() + + .. TODO(Nice Zombies) + + .. versionadded:: 3.14 + + .. method:: iter_nowait() + + .. TODO(Nice Zombies) + + .. versionadded:: 3.14 + .. coroutinemethod:: join() Block until all items in the queue have been received and processed. @@ -202,7 +204,7 @@ concurrent tasks:: async def worker(name, queue): # Get a "work item" out of the queue. - async for sleep_for in queue: + async for sleep_for in queue.iter(): # Sleep for the "sleep_for" seconds. await asyncio.sleep(sleep_for) diff --git a/Lib/asyncio/queues.py b/Lib/asyncio/queues.py index f799efa0534c40..2efcbeeba05233 100644 --- a/Lib/asyncio/queues.py +++ b/Lib/asyncio/queues.py @@ -90,8 +90,6 @@ def _wakeup_next(self, waiters): waiter.set_result(None) break - def __aiter__(self): - return _AsyncQueueIterator(self) def __repr__(self): return f'<{type(self).__name__} at {id(self):#x} {self._format()}>' @@ -233,6 +231,23 @@ def get_nowait(self): self._wakeup_next(self._putters) return item + def iter(self): + # TODO(Nice Zombies) + return _AsyncQueueIterator(self) + + def iter_nowait(self): + # TODO(Nice Zombies) + try: + yield self.get_nowait() + except QueueShutDown: + return + + try: + while True: + yield self.get_nowait() + except (QueueEmpty, QueueShutDown): + return + def task_done(self): """Indicate that a formerly enqueued task is complete. diff --git a/Lib/test/test_asyncio/test_queues.py b/Lib/test/test_asyncio/test_queues.py index c5f8e4b36141d1..56c07d0936f5b2 100644 --- a/Lib/test/test_asyncio/test_queues.py +++ b/Lib/test/test_asyncio/test_queues.py @@ -116,23 +116,40 @@ async def putter(): self.assertTrue(t.done()) self.assertTrue(t.result()) - async def test_aiter(self): + async def test_iter(self): q = asyncio.Queue() - for i in range(100): - q.put_nowait(i) + accumulator = 0 - # All tasks have been queued - q.shutdown() + async def worker(): + nonlocal accumulator + + async for item in q.iter(): + accumulator += item + + async with asyncio.TaskGroup() as tg: + tg.create_task(worker()) + tg.create_task(worker()) + for i in range(100): + q.put_nowait(i) + + q.shutdown() + self.assertEqual(sum(range(100)), accumulator) + + async def test_iter_nowait(self): + q = asyncio.Queue() accumulator = 0 async def worker(): nonlocal accumulator - async for item in q: + for item in q.iter_nowait(): accumulator += item async with asyncio.TaskGroup() as tg: + for i in range(100): + q.put_nowait(i) + tg.create_task(worker()) tg.create_task(worker()) @@ -497,7 +514,7 @@ async def test_task_done(self): async def worker(): nonlocal accumulator - async for item in q: + async for item in q.iter(): accumulator += item q.task_done() From 5d6681a231e8624bc90fb572e3497a3d72d37205 Mon Sep 17 00:00:00 2001 From: Nineteendo Date: Sun, 23 Jun 2024 21:57:11 +0200 Subject: [PATCH 32/42] Fix lint --- Lib/asyncio/queues.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/asyncio/queues.py b/Lib/asyncio/queues.py index 2efcbeeba05233..c6bd8b902f7e2c 100644 --- a/Lib/asyncio/queues.py +++ b/Lib/asyncio/queues.py @@ -234,7 +234,7 @@ def get_nowait(self): def iter(self): # TODO(Nice Zombies) return _AsyncQueueIterator(self) - + def iter_nowait(self): # TODO(Nice Zombies) try: From 823389f024af72cb11a596553dbd91be6716a0bb Mon Sep 17 00:00:00 2001 From: Nineteendo Date: Sun, 23 Jun 2024 22:08:44 +0200 Subject: [PATCH 33/42] Don't use multiple threads --- Lib/test/test_asyncio/test_queues.py | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/Lib/test/test_asyncio/test_queues.py b/Lib/test/test_asyncio/test_queues.py index 56c07d0936f5b2..f22df5e54cb05f 100644 --- a/Lib/test/test_asyncio/test_queues.py +++ b/Lib/test/test_asyncio/test_queues.py @@ -139,19 +139,11 @@ async def worker(): async def test_iter_nowait(self): q = asyncio.Queue() accumulator = 0 + for i in range(100): + q.put_nowait(i) - async def worker(): - nonlocal accumulator - - for item in q.iter_nowait(): - accumulator += item - - async with asyncio.TaskGroup() as tg: - for i in range(100): - q.put_nowait(i) - - tg.create_task(worker()) - tg.create_task(worker()) + for item in q.iter_nowait(): + accumulator += item self.assertEqual(sum(range(100)), accumulator) @@ -206,6 +198,8 @@ def test_nonblocking_get(self): def test_nonblocking_get_exception(self): q = asyncio.Queue() self.assertRaises(asyncio.QueueEmpty, q.get_nowait) + with self.assertRaises(asyncio.QueueEmpty): + list(q.iter_nowait()) async def test_get_cancelled_race(self): q = asyncio.Queue() @@ -600,6 +594,7 @@ async def test_shutdown_empty(self): await q.get() with self.assertRaisesShutdown(): q.get_nowait() + self.assertEqual(list(q.iter_nowait()), []) async def test_shutdown_nonempty(self): # Test shutting down a non-empty queue @@ -644,6 +639,7 @@ async def test_shutdown_nonempty(self): await q.get() with self.assertRaisesShutdown(): q.get_nowait() + self.assertEqual(list(q.iter_nowait()), []) # Ensure there is 1 unfinished task, and join() task succeeds q.task_done() @@ -686,6 +682,7 @@ async def test_shutdown_immediate(self): await q.get() with self.assertRaisesShutdown(): q.get_nowait() + self.assertEqual(list(q.iter_nowait()), []) # Ensure there are no unfinished tasks with self.assertRaises( From 104423a06a9d582b4baf58b380af23cb9dca7367 Mon Sep 17 00:00:00 2001 From: Nineteendo Date: Sun, 23 Jun 2024 22:21:15 +0200 Subject: [PATCH 34/42] Add docstrings --- Doc/library/asyncio-queue.rst | 12 ++++++++++-- Lib/asyncio/queues.py | 14 ++++++++++++-- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/Doc/library/asyncio-queue.rst b/Doc/library/asyncio-queue.rst index 9f2eb1053f2eb3..fe44157a9ef249 100644 --- a/Doc/library/asyncio-queue.rst +++ b/Doc/library/asyncio-queue.rst @@ -72,13 +72,21 @@ Queue .. method:: iter() - .. TODO(Nice Zombies) + Return an :term:`asynchronous iterator` which iterates over the queue + of items. If queue is empty, wait until the next item is available. + + Stops iteration if the queue has been shut down and is empty, or if + the queue has been shut down immediately. .. versionadded:: 3.14 .. method:: iter_nowait() - .. TODO(Nice Zombies) + Return an :term:`iterator` which iterates over the queue of items + without blocking. + + Only iterate over the items which are immediately available, but raise + the :exc:`QueueEmpty` exception if none are. .. versionadded:: 3.14 diff --git a/Lib/asyncio/queues.py b/Lib/asyncio/queues.py index c6bd8b902f7e2c..e42584f95326d0 100644 --- a/Lib/asyncio/queues.py +++ b/Lib/asyncio/queues.py @@ -232,11 +232,21 @@ def get_nowait(self): return item def iter(self): - # TODO(Nice Zombies) + """Return an asynchronous iterator which iterates over the queue of + items. If queue is empty, wait until the next item is available. + + Stops iteration if the queue has been shut down and is empty, or if the + queue has been shut down immediately. + """ return _AsyncQueueIterator(self) def iter_nowait(self): - # TODO(Nice Zombies) + """Return an iterator which iterates over the queue of items without + blocking. + + Only iterate over the items which are immediately available, but raise + the QueueEmpty exception if none are. + """ try: yield self.get_nowait() except QueueShutDown: From d3e06d4119008cd2bb9f8f7c3e28794efe44791c Mon Sep 17 00:00:00 2001 From: Nineteendo Date: Sun, 23 Jun 2024 22:23:09 +0200 Subject: [PATCH 35/42] Revert newline --- Lib/asyncio/queues.py | 1 - 1 file changed, 1 deletion(-) diff --git a/Lib/asyncio/queues.py b/Lib/asyncio/queues.py index e42584f95326d0..94767edc249543 100644 --- a/Lib/asyncio/queues.py +++ b/Lib/asyncio/queues.py @@ -90,7 +90,6 @@ def _wakeup_next(self, waiters): waiter.set_result(None) break - def __repr__(self): return f'<{type(self).__name__} at {id(self):#x} {self._format()}>' From f5aeeacb6c30cad9c9ca5945b0a755d4b573d19d Mon Sep 17 00:00:00 2001 From: Nice Zombies Date: Sun, 23 Jun 2024 22:23:32 +0200 Subject: [PATCH 36/42] Delete Misc/NEWS.d/next/Library/2024-06-14-10-30-43.gh-issue-119154.1MHWA-.rst --- .../next/Library/2024-06-14-10-30-43.gh-issue-119154.1MHWA-.rst | 2 -- 1 file changed, 2 deletions(-) delete mode 100644 Misc/NEWS.d/next/Library/2024-06-14-10-30-43.gh-issue-119154.1MHWA-.rst diff --git a/Misc/NEWS.d/next/Library/2024-06-14-10-30-43.gh-issue-119154.1MHWA-.rst b/Misc/NEWS.d/next/Library/2024-06-14-10-30-43.gh-issue-119154.1MHWA-.rst deleted file mode 100644 index 38bd9c61c33422..00000000000000 --- a/Misc/NEWS.d/next/Library/2024-06-14-10-30-43.gh-issue-119154.1MHWA-.rst +++ /dev/null @@ -1,2 +0,0 @@ -Make :class:`asyncio.Queue` an :term:`asynchronous iterable`. -(Contributed by Wannes Boeykens in :gh:`120491`.) From fb98fa68b6a9d10d756e72f484bde1e868245d6d Mon Sep 17 00:00:00 2001 From: Nineteendo Date: Sun, 23 Jun 2024 22:26:26 +0200 Subject: [PATCH 37/42] Update whatsnew --- Doc/whatsnew/3.14.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Doc/whatsnew/3.14.rst b/Doc/whatsnew/3.14.rst index c7f4db10c9fafc..7863d0378e675f 100644 --- a/Doc/whatsnew/3.14.rst +++ b/Doc/whatsnew/3.14.rst @@ -95,8 +95,8 @@ Added :func:`ast.compare` for comparing two ASTs. asyncio ------- -Made :class:`asyncio.Queue` an :term:`asynchronous iterable`. -(Contributed by Wannes Boeykens in :gh:`120491`.) +Add :meth:`asyncio.Queue.iter` and :meth:`asyncio.Queue.iter_nowait`. +(Contributed by Wannes Boeykens in ``gh-???`120925``.) os -- From a56505dabbafd0a2eae6f55055f6f5a0a679c801 Mon Sep 17 00:00:00 2001 From: Nineteendo Date: Sun, 23 Jun 2024 22:26:51 +0200 Subject: [PATCH 38/42] Fix typo --- Doc/whatsnew/3.14.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/whatsnew/3.14.rst b/Doc/whatsnew/3.14.rst index 7863d0378e675f..0d3b2979c3915d 100644 --- a/Doc/whatsnew/3.14.rst +++ b/Doc/whatsnew/3.14.rst @@ -96,7 +96,7 @@ asyncio ------- Add :meth:`asyncio.Queue.iter` and :meth:`asyncio.Queue.iter_nowait`. -(Contributed by Wannes Boeykens in ``gh-???`120925``.) +(Contributed by Wannes Boeykens in ``gh-???``.) os -- From 6f146f5282d78118e7c4ad7b90b9755877454d53 Mon Sep 17 00:00:00 2001 From: "blurb-it[bot]" <43283697+blurb-it[bot]@users.noreply.github.com> Date: Sun, 23 Jun 2024 20:32:00 +0000 Subject: [PATCH 39/42] =?UTF-8?q?=F0=9F=93=9C=F0=9F=A4=96=20Added=20by=20b?= =?UTF-8?q?lurb=5Fit.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../next/Library/2024-06-23-20-31-59.gh-issue-120924.2AiErS.rst | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 Misc/NEWS.d/next/Library/2024-06-23-20-31-59.gh-issue-120924.2AiErS.rst diff --git a/Misc/NEWS.d/next/Library/2024-06-23-20-31-59.gh-issue-120924.2AiErS.rst b/Misc/NEWS.d/next/Library/2024-06-23-20-31-59.gh-issue-120924.2AiErS.rst new file mode 100644 index 00000000000000..b9bb86ca9dab74 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2024-06-23-20-31-59.gh-issue-120924.2AiErS.rst @@ -0,0 +1,2 @@ +Add :meth:`asyncio.Queue.iter` and :meth:`asyncio.Queue.iter_nowait`. +(Contributed by Wannes Boeykens in :gh:`120927`.) From 0bbcfddc94101b0d412e94dcf5b1f4ce2961df22 Mon Sep 17 00:00:00 2001 From: Nineteendo Date: Sun, 23 Jun 2024 22:32:41 +0200 Subject: [PATCH 40/42] Update whatsnew --- Doc/whatsnew/3.14.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/whatsnew/3.14.rst b/Doc/whatsnew/3.14.rst index 0d3b2979c3915d..7c5c033a348253 100644 --- a/Doc/whatsnew/3.14.rst +++ b/Doc/whatsnew/3.14.rst @@ -96,7 +96,7 @@ asyncio ------- Add :meth:`asyncio.Queue.iter` and :meth:`asyncio.Queue.iter_nowait`. -(Contributed by Wannes Boeykens in ``gh-???``.) +(Contributed by Wannes Boeykens in :gh:`120927`.) os -- From 81da0e6a17cbe29de1fa3b32808e0d0e2ebfae86 Mon Sep 17 00:00:00 2001 From: Nice Zombies Date: Mon, 24 Jun 2024 09:17:43 +0200 Subject: [PATCH 41/42] Update 3.14.rst --- Doc/whatsnew/3.14.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/whatsnew/3.14.rst b/Doc/whatsnew/3.14.rst index 7c5c033a348253..c75af9edce2065 100644 --- a/Doc/whatsnew/3.14.rst +++ b/Doc/whatsnew/3.14.rst @@ -96,7 +96,7 @@ asyncio ------- Add :meth:`asyncio.Queue.iter` and :meth:`asyncio.Queue.iter_nowait`. -(Contributed by Wannes Boeykens in :gh:`120927`.) +(Contributed by Wannes Boeykens in :gh:`120925`.) os -- From 461d1e164e690e3dc8c1b842de94cda3db3435ed Mon Sep 17 00:00:00 2001 From: Nice Zombies Date: Mon, 24 Jun 2024 09:18:00 +0200 Subject: [PATCH 42/42] Delete Misc/NEWS.d/next/Library/2024-06-23-20-31-59.gh-issue-120924.2AiErS.rst --- .../next/Library/2024-06-23-20-31-59.gh-issue-120924.2AiErS.rst | 2 -- 1 file changed, 2 deletions(-) delete mode 100644 Misc/NEWS.d/next/Library/2024-06-23-20-31-59.gh-issue-120924.2AiErS.rst diff --git a/Misc/NEWS.d/next/Library/2024-06-23-20-31-59.gh-issue-120924.2AiErS.rst b/Misc/NEWS.d/next/Library/2024-06-23-20-31-59.gh-issue-120924.2AiErS.rst deleted file mode 100644 index b9bb86ca9dab74..00000000000000 --- a/Misc/NEWS.d/next/Library/2024-06-23-20-31-59.gh-issue-120924.2AiErS.rst +++ /dev/null @@ -1,2 +0,0 @@ -Add :meth:`asyncio.Queue.iter` and :meth:`asyncio.Queue.iter_nowait`. -(Contributed by Wannes Boeykens in :gh:`120927`.)