diff --git a/setupext.py b/setupext.py index 5479573b276d..32444984adee 100755 --- a/setupext.py +++ b/setupext.py @@ -13,7 +13,6 @@ import warnings from textwrap import fill - PY3 = (sys.version_info[0] >= 3) @@ -1788,16 +1787,26 @@ def check_requirements(self): except: return "unknown (can not use multiprocessing to determine)" try: - success, msg = p.map(backend_gtk3agg_internal_check, [0])[0] + res = p.map_async(backend_gtk3agg_internal_check, [0]) + success, msg = res.get(timeout=10)[0] + except multiprocessing.TimeoutError: + p.terminate() + # No result returned. Probaly hanging, terminate the process. + success = False + raise CheckFailed("Check timed out") except: + p.close() + # Some other error. success = False msg = "Could not determine" - finally: + raise + else: p.close() + finally: p.join() + if success: BackendAgg.force = True - return msg else: raise CheckFailed(msg) @@ -1852,12 +1861,25 @@ def check_requirements(self): p = multiprocessing.Pool() except: return "unknown (can not use multiprocessing to determine)" - success, msg = p.map(backend_gtk3cairo_internal_check, [0])[0] - p.close() - p.join() + try: + res = p.map_async(backend_gtk3cairo_internal_check, [0]) + success, msg = res.get(timeout=10)[0] + except multiprocessing.TimeoutError: + p.terminate() + # No result returned. Probaly hanging, terminate the process. + success = False + raise CheckFailed("Check timed out") + except: + p.close() + success = False + raise + else: + p.close() + finally: + p.join() + if success: BackendAgg.force = True - return msg else: raise CheckFailed(msg) @@ -1988,13 +2010,21 @@ def check_requirements(self): else: # Multiprocessing OK try: - msg = p.map(self.callback, [self])[0] + res = p.map_async(self.callback, [self]) + msg = res.get(timeout=10)[0] + except multiprocessing.TimeoutError: + p.terminate() + # No result returned. Probaly hanging, terminate the process. + raise CheckFailed("Check timed out") except: - # If we hit an error on multiprocessing raise it + # Some other error. + p.close() raise + else: + # Clean exit + p.close() finally: # Tidy up multiprocessing - p.close() p.join() return msg