WatchdogPriorityQueue: fix watchdog sentinel insertion

We now force each inserted item in the priority queue to be a tuple and the
actual value to be last in the tuple. All the previous values in the tuple also
need to be numeric.
This commit is contained in:
Aleix Conchillo Flaqué
2025-08-12 15:28:03 -07:00
parent 54a4d8a9f8
commit 0508ddddfb
5 changed files with 40 additions and 21 deletions

View File

@@ -41,7 +41,7 @@ class TestWatchdogQueue(unittest.IsolatedAsyncioTestCase):
class TestWatchdogPriorityQueue(unittest.IsolatedAsyncioTestCase):
async def test_simple_item(self):
queue = WatchdogPriorityQueue(TaskManager())
queue = WatchdogPriorityQueue(TaskManager(), tuple_size=2)
await queue.put((3, 1))
await queue.put((2, 1))
await queue.put((1, 1))
@@ -53,7 +53,7 @@ class TestWatchdogPriorityQueue(unittest.IsolatedAsyncioTestCase):
queue.task_done()
async def test_watchdog_sentinel(self):
queue = WatchdogPriorityQueue(TaskManager())
queue = WatchdogPriorityQueue(TaskManager(), tuple_size=2)
await queue.put((0, 1))
# The get should throw an exception because the watchdog sentinel has
# higher priority.