anaconda/backport-Remove-initThreading-method-from-pyanaconda-threading.patch

70 lines
2.3 KiB
Diff

From 05bda4c50c9df594a6b266ac74b60478da4c532c Mon Sep 17 00:00:00 2001
From: fengtao <fengtao40@huawei.com>
Date: Wed, 12 Feb 2020 15:52:08 +0800
Subject: [PATCH] Remove initThreading method from pyanaconda threading
---
anaconda.py | 5 +----
pyanaconda/threading.py | 17 +----------------
2 files changed, 2 insertions(+), 20 deletions(-)
diff --git a/anaconda.py b/anaconda.py
index 14048e7..52c8826 100755
--- a/anaconda.py
+++ b/anaconda.py
@@ -274,10 +274,7 @@ if __name__ == "__main__":
setup_python_path()
# init threading before Gtk can do anything and before we start using threads
- # initThreading initializes the threadMgr instance, import it afterwards
- from pyanaconda.threading import initThreading, AnacondaThread, threadMgr
- initThreading()
-
+ from pyanaconda.threading import AnacondaThread, threadMgr
from pyanaconda.core.i18n import _
from pyanaconda.addons import collect_addon_paths
diff --git a/pyanaconda/threading.py b/pyanaconda/threading.py
index a86003d..e0ab802 100644
--- a/pyanaconda/threading.py
+++ b/pyanaconda/threading.py
@@ -44,10 +44,6 @@ class ThreadManager(object):
self._objs_lock = threading.RLock()
self._errors = {}
self._errors_lock = threading.RLock()
- self._main_thread = threading.main_thread()
-
- def set_current_thread_as_main(self):
- self._main_thread = threading.current_thread()
def __call__(self):
return self
@@ -176,9 +172,7 @@ class ThreadManager(object):
def in_main_thread(self):
"""Return True if it is run in the main thread."""
-
- cur_thread = threading.current_thread()
- return cur_thread is self._main_thread
+ return threading.current_thread() is threading.main_thread()
@property
def running(self):
@@ -293,13 +287,4 @@ class AnacondaThread(threading.Thread):
self._target_stopped()
-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.
- """
- threadMgr.set_current_thread_as_main()
-
-
threadMgr = ThreadManager()
--
1.8.3.1