[PATCH 1/2] Initialize threading when the module is imported.
David Shea
dshea at redhat.com
Fri Aug 22 16:25:37 UTC 2014
This way threadMgr is initialized the first time the module is loaded
and is never set to None.
Related: rhbz#1125927
---
anaconda | 8 +++-----
pyanaconda/threads.py | 7 +++----
2 files changed, 6 insertions(+), 9 deletions(-)
diff --git a/anaconda b/anaconda
index ffce0f0..55fe188 100755
--- a/anaconda
+++ b/anaconda
@@ -691,11 +691,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
from pyanaconda import constants
from pyanaconda import addons
diff --git a/pyanaconda/threads.py b/pyanaconda/threads.py
index 3768452..efe7d2e 100644
--- a/pyanaconda/threads.py
+++ b/pyanaconda/threads.py
@@ -218,7 +218,7 @@ 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
@@ -227,7 +227,6 @@ def initThreading():
from gi.repository import GObject
GObject.threads_init()
- global threadMgr
- threadMgr = ThreadManager()
+ return ThreadManager()
-threadMgr = None
+threadMgr = _initThreading()
--
1.9.3
More information about the anaconda-patches
mailing list