[gnome-music/wip/mschraal/file-exists-async: 4/8] Reset I/O priorities




commit 951820c3961e47e3098ce76110e07d6e4d07b130
Author: Marinus Schraal <mschraal gnome org>
Date:   Sun Aug 15 22:50:47 2021 +0200

    Reset I/O priorities
    
    Previously Music would set most async I/O priorities as low as possible
    to give the main thread space. With recent async improvements, the low
    priorities make less sense.
    
    Reset most I/O priorities to default. Make the albumsview on
    demand cover loading priority a little higher as it is the main view.

 gnomemusic/artcache.py         | 5 +++--
 gnomemusic/embeddedart.py      | 2 +-
 gnomemusic/fileexistsasync.py  | 2 +-
 gnomemusic/storeart.py         | 8 ++++----
 gnomemusic/views/albumsview.py | 2 +-
 5 files changed, 10 insertions(+), 9 deletions(-)
---
diff --git a/gnomemusic/artcache.py b/gnomemusic/artcache.py
index 878eeed52..62e364090 100644
--- a/gnomemusic/artcache.py
+++ b/gnomemusic/artcache.py
@@ -83,7 +83,7 @@ class ArtCache(GObject.GObject):
         thumb_file = Gio.File.new_for_uri(thumbnail_uri)
         if thumb_file:
             thumb_file.read_async(
-                GLib.PRIORITY_LOW, None, self._open_stream, None)
+                GLib.PRIORITY_DEFAULT, None, self._open_stream, None)
             return
 
         self.emit("finished", self._default_icon)
@@ -109,7 +109,8 @@ class ArtCache(GObject.GObject):
             self.emit("finished", self._default_icon)
             return
 
-        stream.close_async(GLib.PRIORITY_LOW, None, self._close_stream, None)
+        stream.close_async(
+            GLib.PRIORITY_DEFAULT, None, self._close_stream, None)
 
         surface = Gdk.cairo_surface_create_from_pixbuf(
             pixbuf, self._scale, None)
diff --git a/gnomemusic/embeddedart.py b/gnomemusic/embeddedart.py
index 7ef4f93d4..1d2c4afc0 100644
--- a/gnomemusic/embeddedart.py
+++ b/gnomemusic/embeddedart.py
@@ -160,7 +160,7 @@ class EmbeddedArt(GObject.GObject):
         self._media_art.uri_async(
             MediaArt.Type.ALBUM, MediaArt.ProcessFlags.NONE,
             self._coreobject.props.url, self._artist, self._album,
-            GLib.PRIORITY_LOW, None, self._uri_async_cb, None)
+            GLib.PRIORITY_DEFAULT, None, self._uri_async_cb, None)
 
     def _uri_async_cb(self, src, result, data):
         try:
diff --git a/gnomemusic/fileexistsasync.py b/gnomemusic/fileexistsasync.py
index 7abfe93b5..67d913873 100644
--- a/gnomemusic/fileexistsasync.py
+++ b/gnomemusic/fileexistsasync.py
@@ -39,7 +39,7 @@ class FileExistsAsync(GObject.GObject):
     def start(self, thumb_file: Gio.File) -> None:
         thumb_file.query_info_async(
             Gio.FILE_ATTRIBUTE_STANDARD_TYPE, Gio.FileQueryInfoFlags.NONE,
-            GLib.PRIORITY_HIGH_IDLE, None, self._on_query_info_finished)
+            GLib.PRIORITY_DEFAULT, None, self._on_query_info_finished)
 
     def _on_query_info_finished(
             self, thumb_file: Gio.File, res: Gio.AsyncResult) -> None:
diff --git a/gnomemusic/storeart.py b/gnomemusic/storeart.py
index 89f13c0ec..1ae2e4c04 100644
--- a/gnomemusic/storeart.py
+++ b/gnomemusic/storeart.py
@@ -67,7 +67,7 @@ class StoreArt(GObject.Object):
         cache_dir_file = Gio.File.new_for_path(cache_dir)
         cache_dir_file.query_info_async(
             Gio.FILE_ATTRIBUTE_ACCESS_CAN_READ, Gio.FileQueryInfoFlags.NONE,
-            GLib.PRIORITY_LOW, None, self._cache_dir_info_read, uri)
+            GLib.PRIORITY_DEFAULT, None, self._cache_dir_info_read, uri)
 
     def _cache_dir_info_read(self, cache_dir_file, res, uri):
         try:
@@ -109,7 +109,7 @@ class StoreArt(GObject.Object):
         # closed. PyGI specific issue?
         ostream.splice_async(
             istream, Gio.OutputStreamSpliceFlags.CLOSE_SOURCE
-            | Gio.OutputStreamSpliceFlags.CLOSE_TARGET, GLib.PRIORITY_LOW,
+            | Gio.OutputStreamSpliceFlags.CLOSE_TARGET, GLib.PRIORITY_DEFAULT,
             None, self._splice_callback, [tmp_file, iostream])
 
     def _delete_callback(self, src, result, data):
@@ -123,7 +123,7 @@ class StoreArt(GObject.Object):
         tmp_file, iostream = data
 
         iostream.close_async(
-            GLib.PRIORITY_LOW, None, self._close_iostream_callback, None)
+            GLib.PRIORITY_DEFAULT, None, self._close_iostream_callback, None)
 
         try:
             src.splice_finish(result)
@@ -169,7 +169,7 @@ class StoreArt(GObject.Object):
         self.emit("finished")
 
         tmp_file.delete_async(
-            GLib.PRIORITY_LOW, None, self._delete_callback, None)
+            GLib.PRIORITY_DEFAULT, None, self._delete_callback, None)
 
     def _close_iostream_callback(self, src, result, data):
         try:
diff --git a/gnomemusic/views/albumsview.py b/gnomemusic/views/albumsview.py
index 38806f57f..05c7f49a5 100644
--- a/gnomemusic/views/albumsview.py
+++ b/gnomemusic/views/albumsview.py
@@ -106,7 +106,7 @@ class AlbumsView(Gtk.Stack):
 
         self._adjustment_timeout_id = GLib.timeout_add(
             200, self._retrieve_covers, adjustment.props.value,
-            priority=GLib.PRIORITY_LOW)
+            priority=GLib.PRIORITY_DEFAULT - 10)
 
     def _retrieve_covers(self, old_adjustment):
         adjustment = self._scrolled_window.props.vadjustment.props.value


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