[gnome-music/wip/mschraal/asyncqueue-fixes: 22/29] asyncqueue: Add a simple FIFO queue




commit 8d3a4769bbfb0316564dc9dcbb727ab853a08dcf
Author: Marinus Schraal <mschraal gnome org>
Date:   Tue Sep 7 09:49:13 2021 +0200

    asyncqueue: Add a simple FIFO queue
    
    By default dict popitem is LIFO, while FIFO is preferred for our use
    case.
    
    Implement a simple form of FIFO.

 gnomemusic/asyncqueue.py | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
---
diff --git a/gnomemusic/asyncqueue.py b/gnomemusic/asyncqueue.py
index 703bce629..84b0eb379 100644
--- a/gnomemusic/asyncqueue.py
+++ b/gnomemusic/asyncqueue.py
@@ -98,7 +98,8 @@ class AsyncQueue(GObject.GObject):
             self._timeout_id = 0
             return GLib.SOURCE_REMOVE
         elif len(self._async_active_pool) < self._max_async:
-            async_obj_id, async_task_args = self._async_pool.popitem()
+            async_obj_id = list(self._async_pool.keys())[0]
+            async_task_args = self._async_pool.pop(async_obj_id)
             async_obj = async_task_args[0]
             self._async_active_pool[async_obj_id] = async_task_args
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]