[gnome-music/wip/mschraal/async-queue: 3/8] artcache: Use AsyncQueue for cache retrieval
- From: Marinus Schraal <mschraal src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-music/wip/mschraal/async-queue: 3/8] artcache: Use AsyncQueue for cache retrieval
- Date: Wed, 11 Aug 2021 14:15:27 +0000 (UTC)
commit 62d4208f5ce39992fea97d980f2bb86384e5b2c7
Author: Marinus Schraal <mschraal gnome org>
Date: Tue Aug 10 15:15:55 2021 +0200
artcache: Use AsyncQueue for cache retrieval
gnomemusic/artcache.py | 3 ++-
gnomemusic/asyncqueue.py | 4 ++--
gnomemusic/widgets/artstack.py | 6 +++++-
3 files changed, 9 insertions(+), 4 deletions(-)
---
diff --git a/gnomemusic/artcache.py b/gnomemusic/artcache.py
index 96d266ef9..49f94a3b6 100644
--- a/gnomemusic/artcache.py
+++ b/gnomemusic/artcache.py
@@ -24,7 +24,7 @@
from enum import Enum
from math import pi
-from typing import Dict, Tuple
+from typing import Dict, Tuple, Union
import cairo
from gi.repository import Gdk, GdkPixbuf, Gio, Gtk, GLib, GObject
@@ -240,3 +240,4 @@ class ArtCache(GObject.GObject):
except GLib.Error as error:
self._log.warning(
"Error: {}, {}".format(error.domain, error.message))
+
diff --git a/gnomemusic/asyncqueue.py b/gnomemusic/asyncqueue.py
index 4439cf87a..870ed32cf 100644
--- a/gnomemusic/asyncqueue.py
+++ b/gnomemusic/asyncqueue.py
@@ -22,7 +22,7 @@
# code, but you are not obligated to do so. If you do not wish to do so,
# delete this exception statement from your version.
-from typing import Dict, Tuple
+from typing import Any, Dict, Tuple
from gi.repository import GObject
@@ -52,7 +52,7 @@ class AsyncQueue(GObject.GObject):
self._async_active_pool: Dict[int, Tuple] = {}
self._max_async = 4
- def queue(self, *args) -> None:
+ def queue(self, *args: Any) -> None:
"""Queue an async call
"""
async_obj = args[0]
diff --git a/gnomemusic/widgets/artstack.py b/gnomemusic/widgets/artstack.py
index 9a6a87c46..5d0dda198 100644
--- a/gnomemusic/widgets/artstack.py
+++ b/gnomemusic/widgets/artstack.py
@@ -24,6 +24,7 @@
from gi.repository import GObject, Gtk
+from gnomemusic.asyncqueue import AsyncQueue
from gnomemusic.artcache import ArtCache
from gnomemusic.utils import ArtSize
@@ -38,6 +39,8 @@ class ArtStack(Gtk.Stack):
__gtype_name__ = "ArtStack"
+ _async_queue = AsyncQueue()
+
def __init__(self, size=ArtSize.MEDIUM):
"""Initialize the ArtStack
@@ -104,7 +107,8 @@ class ArtStack(Gtk.Stack):
self._handler_id = self._cache.connect("result", self._on_cache_result)
- self._cache.query(coreobject, self._size, self.props.scale_factor)
+ self._async_queue.queue(
+ self._cache, coreobject, self._size, self.props.scale_factor)
def _on_cache_result(self, cache, surface):
if self.props.visible_child_name == "B":
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]