[gnome-music/wip/mschraal/asyncqueue-fixes: 2/2] asyncqueue: Add a simple FIFO queue
- From: Marinus Schraal <mschraal src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-music/wip/mschraal/asyncqueue-fixes: 2/2] asyncqueue: Add a simple FIFO queue
- Date: Tue, 7 Sep 2021 08:10:13 +0000 (UTC)
commit 1750b80b975fe0357698dcb7c421d71a7c6ac40f
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]