From 7e8e04d7c9d1cab4f0472cf2e842585ffaf66f2d Mon Sep 17 00:00:00 2001 From: Jusong Yu Date: Sun, 1 Dec 2024 19:52:40 +0100 Subject: [PATCH] Refresh task queue first before get task from queue --- src/kiwipy/rmq/tasks.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/kiwipy/rmq/tasks.py b/src/kiwipy/rmq/tasks.py index 4fc1e6f..cf5aa18 100644 --- a/src/kiwipy/rmq/tasks.py +++ b/src/kiwipy/rmq/tasks.py @@ -119,6 +119,9 @@ async def next_task(self, raises: kiwipy.exceptions.QueueEmpty: When the queue has no tasks within the timeout """ + # relinquish so that if there is requeue coroutines, they are run first and task queue get updated + await asyncio.sleep(0) + try: message = await self._task_queue.get(no_ack=no_ack, fail=fail, timeout=timeout) except aio_pika.exceptions.QueueEmpty as exc: