From 5d6228b85e174dee8abcc4c206a1e9034242c6c6 Mon Sep 17 00:00:00 2001 From: "Bryn M. Reeves" Date: Fri, 7 Sep 2018 12:06:34 -0400 Subject: [sosreport] ensure ThreadPool exceptions are raised The ThreadPoolExecutor does not raise exceptions to the parent thread immediately: it stores them in-line in the pool's results list, and raises them to the caller on acccess to that slot in the results iterator. Make sure that these exceptions are handled by iterating over all results and asserting that they are non-None (in practice, this code is never executed since the resulting raise will trap to an exception handler, but it is less confusing than a bare 'pass'). Signed-off-by: Bryn M. Reeves --- sos/sosreport.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/sos/sosreport.py b/sos/sosreport.py index 80633966..44be75a1 100644 --- a/sos/sosreport.py +++ b/sos/sosreport.py @@ -1065,9 +1065,13 @@ class SoSReport(object): try: self.plugpool = ThreadPoolExecutor(self.opts.threads) # Pass the plugpool its own private copy of self.pluglist - self.plugpool.map(self._collect_plugin, list(self.pluglist), - chunksize=1) + results = self.plugpool.map(self._collect_plugin, + list(self.pluglist), chunksize=1) self.plugpool.shutdown(wait=True) + for res in results: + if not res: + self.soslog.debug("Unexpected plugin task result: %s" % + res) self.ui_log.info("") except KeyboardInterrupt: # We may not be at a newline when the user issues Ctrl-C -- cgit