[PATCH 1/3] Initialize threading when the module is imported.

David Shea dshea at redhat.com
Fri Aug 22 21:19:33 UTC 2014


This way threadMgr is initialized the first time the module is loaded
and is never set to None.
---
 anaconda              | 8 +++-----
 pyanaconda/threads.py | 7 +++----
 2 files changed, 6 insertions(+), 9 deletions(-)

diff --git a/anaconda b/anaconda
index 7fb9370..1cffff7 100755
--- a/anaconda
+++ b/anaconda
@@ -903,11 +903,9 @@ if __name__ == "__main__":
     setupPythonUpdates()
     setupPythonPath()
 
-    # init threading before Gtk can do anything and before we start using threads
-    # initThreading initializes the threadMgr instance, import it afterwards
-    from pyanaconda.threads import initThreading, AnacondaThread
-    initThreading()
-    from pyanaconda.threads import threadMgr
+    # Import and initialize threading before Gtk can do anything and before we
+    # start using threads.
+    from pyanaconda.threads import threadMgr, AnacondaThread
 
     import gettext
     _ = lambda x: gettext.ldgettext("anaconda", x)
diff --git a/pyanaconda/threads.py b/pyanaconda/threads.py
index eea1da6..7511195 100644
--- a/pyanaconda/threads.py
+++ b/pyanaconda/threads.py
@@ -234,13 +234,12 @@ class AnacondaThread(threading.Thread):
             threadMgr.remove(self.name)
             log.info("Thread Done: %s (%s)", self.name, self.ident)
 
-def initThreading():
+def _initThreading():
     """Set up threading for anaconda's use. This method must be called before
        any GTK or threading code is called, or else threads will only run when
        an event is triggered in the GTK main loop. And IT HAS TO BE CALLED IN
        THE MAIN THREAD.
     """
-    global threadMgr
-    threadMgr = ThreadManager()
+    return ThreadManager()
 
-threadMgr = None
+threadMgr = _initThreading()
-- 
1.9.3



More information about the anaconda-patches mailing list