Blob Blame History Raw
From 0a21382a7e76ce06bd484add725be3c5e41b216a Mon Sep 17 00:00:00 2001
From: Martin Kolman <mkolman@redhat.com>
Date: Thu, 23 Feb 2017 15:07:57 +0100
Subject: [PATCH] Use the init_done signal instead of wait_all() (#1380224)

Using the wait_all() function provided by the Anaconda thread manager
singleton can result in unexpected behavior, as there might still be
threads unrelated to spoke initialization still running when the
function is called. This might result in unnecessary delay before the
OSCAP addon spoke becomes ready and installation can continue.

So use the init_done signal, which is the proper way to wait for
Anaconda spokes to finish initialization.

Also bump the Anaconda version to one that provides the init_done
signal.

Resolves: rhbz#1380224
---
 org_fedora_oscap/gui/spokes/oscap.py | 14 +++++++++++++-

diff --git a/org_fedora_oscap/gui/spokes/oscap.py b/org_fedora_oscap/gui/spokes/oscap.py
index 35f7a75..b476cf9 100644
--- a/org_fedora_oscap/gui/spokes/oscap.py
+++ b/org_fedora_oscap/gui/spokes/oscap.py
@@ -214,6 +214,14 @@ def __init__(self, data, storage, payload, instclass):
 
         self._error = None
 
+        # wait for all Anaconda spokes to initialiuze
+        self._anaconda_spokes_initialized = threading.Event()
+        self.initialization_controller.init_done.connect(self._all_anaconda_spokes_initialized)
+
+    def _all_anaconda_spokes_initialized(self):
+        log.debug("OSCAP addon: Anaconda init_done signal triggered")
+        self._anaconda_spokes_initialized.set()
+
     def initialize(self):
         """
         The initialize method that is called after the instance is created.
@@ -431,7 +439,11 @@ def _init_after_data_fetch(self, wait_for):
 
         # let all initialization and configuration happen before we evaluate the
         # setup
-        threadMgr.wait_all()
+        if not self._anaconda_spokes_initialized.is_set():
+            # only wait (and log the messages) if the event is not set yet
+            log.debug("OSCAP addon: waiting for all Anaconda spokes to be initialized")
+            self._anaconda_spokes_initialized.wait()
+            log.debug("OSCAP addon: all Anaconda spokes have been initialized - continuing")
 
         # try to switch to the chosen profile (if any)
         selected = self._switch_profile()