By running exception handler every time an exception appears in a thread we
block us from using our features provided by the wait method. Some exceptions
may be non-critical and the waiting thread may recover from the erroneous state.
However, we need to give it a chance to do so.
The wait_all method called before we start the actual installation should make
sure there are no abandoned problematic threads that raised exception nobody
cared about.
Signed-off-by: Vratislav Podzimek <vpodzime(a)redhat.com>
---
pyanaconda/exception.py | 2 ++
pyanaconda/threads.py | 6 +++++-
2 files changed, 7 insertions(+), 1 deletion(-)
diff --git a/pyanaconda/exception.py b/pyanaconda/exception.py
index e61cce0..850a616 100644
--- a/pyanaconda/exception.py
+++ b/pyanaconda/exception.py
@@ -297,3 +297,5 @@ f%s(msg, non_ascii)
threadMgr.add(AnacondaThread(name=THREAD_EXCEPTION_HANDLING_TEST,
target=raise_exception,
args=(msg, non_ascii)))
+
+ threadMgr.wait(THREAD_EXCEPTION_HANDLING_TEST)
diff --git a/pyanaconda/threads.py b/pyanaconda/threads.py
index 29290df..dadc75d 100644
--- a/pyanaconda/threads.py
+++ b/pyanaconda/threads.py
@@ -121,6 +121,11 @@ class ThreadManager(object):
log.debug("Waiting for thread %s to exit", name)
self.wait(name)
+ if self.any_errors:
+ msg = "Unhandled errors from the following threads detected: %s"
%\
+ ", ".join(self._errors.iterkeys())
+ raise RuntimeError(msg)
+
def set_error(self, name, *exc_info):
"""Set the error data for a thread
@@ -212,7 +217,6 @@ class AnacondaThread(threading.Thread):
# pylint: disable-msg=W0702
except:
threadMgr.set_error(self.name, *sys.exc_info())
- sys.excepthook(*sys.exc_info())
finally:
threadMgr.remove(self.name)
log.info("Thread Done: %s (%s)", self.name, self.ident)
--
1.8.4.2
Show replies by date