[PATCH] Fix two places where we are locking up the main thread (#886680).

Chris Lumens clumens at redhat.com
Thu Mar 7 15:18:24 UTC 2013


(1) Letting _first_refresh be the first time we reference payload.groups and
payload.environments means we are potentially downloading lots of big data in
the main thread, which means the UI cannot update.

(2) Referencing anything in software.py's _initialize grabs the yum lock,
possibly for a long time.  When we later check the source spoke's status, we
reference ready which checks baseRepo, which also attempts to grab the same
lock.  This isn't a deadlock because it will eventually get released, but it
does make the UI unresponsive for a while.
---
 pyanaconda/ui/gui/spokes/software.py | 24 ++++++++++++++++++------
 pyanaconda/ui/gui/spokes/source.py   |  7 +++----
 2 files changed, 21 insertions(+), 10 deletions(-)

diff --git a/pyanaconda/ui/gui/spokes/software.py b/pyanaconda/ui/gui/spokes/software.py
index bc21af9..14b15c6 100644
--- a/pyanaconda/ui/gui/spokes/software.py
+++ b/pyanaconda/ui/gui/spokes/software.py
@@ -24,6 +24,7 @@ _ = lambda x: gettext.ldgettext("anaconda", x)
 N_ = lambda x: x
 
 from pyanaconda.flags import flags
+from pyanaconda.packaging import MetadataError
 from pyanaconda.threads import threadMgr, AnacondaThread
 
 from pyanaconda.ui import communication
@@ -184,8 +185,25 @@ class SoftwareSelectionSpoke(NormalSpoke):
             # We don't want to do a full refresh, just join the metadata thread
             threadMgr.wait("AnaPayloadMDThread")
         else:
+            # Grabbing the list of groups could potentially take a long time
+            # at first (yum does a lot of magic property stuff, some of which
+            # involves side effects like network access.  We need to reference
+            # them here, outside of the main thread, to not block the UI.
+            try:
+                self.payload.environments
+                self.payload.groups
+            except MetadataError:
+                communication.send_message(self.__class__.__name__,
+                                           _("No installation source available"))
+                return
+
+            # And then having done all that slow downloading, we need to do the first
+            # refresh of the UI here so there's an environment selected by default.
+            # This happens inside the main thread by necessity.  We can't do anything
+            # that takes any real amount of time, or it'll block the UI from updating.
             if not self._first_refresh():
                 return
+
         self.payload.release()
 
         communication.send_ready(self.__class__.__name__)
@@ -196,12 +214,6 @@ class SoftwareSelectionSpoke(NormalSpoke):
 
     @gtk_thread_wait
     def _first_refresh(self):
-        # Grabbing the list of groups could potentially take a long time the
-        # first time (yum does a lot of magic property stuff, some of which
-        # involves side effects like network access) so go ahead and grab
-        # them once now.
-        from pyanaconda.packaging import MetadataError
-
         try:
             self.refresh()
             return True
diff --git a/pyanaconda/ui/gui/spokes/source.py b/pyanaconda/ui/gui/spokes/source.py
index 4b3d90d..6381130 100644
--- a/pyanaconda/ui/gui/spokes/source.py
+++ b/pyanaconda/ui/gui/spokes/source.py
@@ -614,10 +614,9 @@ class SourceSpoke(NormalSpoke):
     @property
     def ready(self):
         from pyanaconda.threads import threadMgr
-        # By default, the source spoke is not ready.  We have to wait until
-        # storageInitialize is done to know whether or not there's local
-        # devices potentially holding install media.
-        return (self._ready and not threadMgr.get("AnaPayloadMDThread") and
+        return (self._ready and
+                not threadMgr.get("AnaPayloadMDThread") and
+                not threadMgr.get("AnaSoftwareWatcher") and
                 not threadMgr.get("AnaCheckSoftwareThread"))
 
     @property
-- 
1.8.1.2



More information about the anaconda-patches mailing list