[llvm] 4dba95f - [lit] Extract `_install_win32_signal_handler` function

Julian Lettner via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 30 15:12:10 PDT 2019


Author: Julian Lettner
Date: 2019-10-30T15:09:43-07:00
New Revision: 4dba95f0ddd760138f3499c8aa7a18deff9ef70c

URL: https://github.com/llvm/llvm-project/commit/4dba95f0ddd760138f3499c8aa7a18deff9ef70c
DIFF: https://github.com/llvm/llvm-project/commit/4dba95f0ddd760138f3499c8aa7a18deff9ef70c.diff

LOG: [lit] Extract `_install_win32_signal_handler` function

Added: 
    

Modified: 
    llvm/utils/lit/lit/run.py

Removed: 
    


################################################################################
diff  --git a/llvm/utils/lit/lit/run.py b/llvm/utils/lit/lit/run.py
index d24cfd47e5a4..4971ce8c050e 100644
--- a/llvm/utils/lit/lit/run.py
+++ b/llvm/utils/lit/lit/run.py
@@ -121,15 +121,7 @@ def _execute(self, deadline):
         pool = multiprocessing.Pool(self.workers, lit.worker.initialize,
                                     (self.lit_config, semaphores))
 
-        # Install a console-control signal handler on Windows.
-        if lit.util.win32api is not None:
-            def console_ctrl_handler(type):
-                print('\nCtrl-C detected, terminating.')
-                pool.terminate()
-                pool.join()
-                lit.util.abort_now()
-                return True
-            lit.util.win32api.SetConsoleCtrlHandler(console_ctrl_handler, True)
+        self._install_win32_signal_handler(pool)
 
         async_results = [
             pool.apply_async(lit.worker.execute, args=[test],
@@ -148,6 +140,7 @@ def console_ctrl_handler(type):
             if self.hit_max_failures:
                 pool.terminate()
                 break
+        pool.join()
 
     # TODO(yln): interferes with progress bar
     # Some tests use threads internally, and at least on Linux each of these
@@ -171,3 +164,13 @@ def _increase_process_limit(self):
                                         (soft_limit, desired_limit))
         except Exception as ex:
             self.lit_config.warning('Failed to raise process limit: %s' % ex)
+
+    def _install_win32_signal_handler(self, pool):
+        if lit.util.win32api is not None:
+            def console_ctrl_handler(type):
+                print('\nCtrl-C detected, terminating.')
+                pool.terminate()
+                pool.join()
+                lit.util.abort_now()
+                return True
+            lit.util.win32api.SetConsoleCtrlHandler(console_ctrl_handler, True)


        


More information about the llvm-commits mailing list