From 6810c20c1bf42a866379d01930414fd13d6a8eb6 Mon Sep 17 00:00:00 2001 From: Reid Kleckner Date: Fri, 17 Nov 2017 23:52:33 +0000 Subject: [PATCH] [lit] Try to improve Ctrl-C behavior on Windows This functionality was broken during a refactor a while back because 'pool' is no longer in scope. llvm-svn: 318572 --- llvm/utils/lit/lit/run.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/llvm/utils/lit/lit/run.py b/llvm/utils/lit/lit/run.py index a4a21234fa3b..c4f9eb2d0fc4 100644 --- a/llvm/utils/lit/lit/run.py +++ b/llvm/utils/lit/lit/run.py @@ -71,6 +71,16 @@ class Run(object): (self.lit_config, self.parallelism_semaphores)) + # Install a console-control signal handler on Windows. + if win32api is not None: + def console_ctrl_handler(type): + print('\nCtrl-C detected, terminating.') + pool.terminate() + pool.join() + abort_now() + return True + win32api.SetConsoleCtrlHandler(console_ctrl_handler, True) + try: async_results = [pool.apply_async(worker_run_one_test, args=(test_index, test), @@ -126,16 +136,6 @@ class Run(object): if not self.tests or jobs == 0: return - # Install a console-control signal handler on Windows. - if win32api is not None: - def console_ctrl_handler(type): - print('\nCtrl-C detected, terminating.') - pool.terminate() - pool.join() - abort_now() - return True - win32api.SetConsoleCtrlHandler(console_ctrl_handler, True) - # Save the display object on the runner so that we can update it from # our task completion callback. self.display = display