From 5254da18432cfefbcfff46fa7b473f8ccfcc0543 Mon Sep 17 00:00:00 2001 From: Aaron Gable Date: Wed, 6 Sep 2017 21:05:39 +0000 Subject: [PATCH] Revert "Capture ctrl-c in presubmit multiprocessing pool" MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit 873c28d17541fd547e2c90de83083a28ea65a8b9. Reason for revert: Broken on Windows (crbug.com/762389) Original change's description: > Capture ctrl-c in presubmit multiprocessing pool > > Presubmit spins up lots of multiprocessing processes to run > each individual test. If you cancel your presubmit run with > +c, that signal gets passed through to each of those, > which then raises its own KeyboardInterrupt, and prints its > own stacktrace. > > This change has each member of the multiprocessing pool instead > exit gracefully (albeit with an error code) so that only the > parent process prints its stacktrace. > > R=​michaelpg@chromium.org > > Bug: 635196 > Change-Id: If9081910a359889a43bc1b72c91a859ebe37a1d6 > Reviewed-on: https://chromium-review.googlesource.com/651764 > Reviewed-by: Robbie Iannucci > Commit-Queue: Aaron Gable TBR=iannucci@chromium.org,agable@chromium.org,michaelpg@chromium.org Change-Id: Ib8e5b2f59b0060dfbfbeba348e211db292318b3b No-Presubmit: true No-Tree-Checks: true No-Try: true Bug: 635196 Reviewed-on: https://chromium-review.googlesource.com/653434 Reviewed-by: Aaron Gable Commit-Queue: Aaron Gable --- presubmit_support.py | 13 ++----------- tests/presubmit_unittest.py | 4 ++-- 2 files changed, 4 insertions(+), 13 deletions(-) diff --git a/presubmit_support.py b/presubmit_support.py index 0af88e556..3bd79fdda 100755 --- a/presubmit_support.py +++ b/presubmit_support.py @@ -30,7 +30,6 @@ import os # Somewhat exposed through the API. import pickle # Exposed through the API. import random import re # Exposed through the API. -import signal import sys # Parts exposed through API. import tempfile # Exposed through the API. import time @@ -436,19 +435,11 @@ class InputApi(object): self.cpu_count = multiprocessing.cpu_count() - # We initialize here because in RunTests, the current working directory has + # this is done here because in RunTests, the current working directory has # changed, which causes Pool() to explode fantastically when run on windows # (because it tries to load the __main__ module, which imports lots of # things relative to the current working directory). - # We capture ctrl-c in the initializer to prevent massive console spew when - # cancelling all of the processes with ctrl-c. - def _capture_interrupt(): - CTRL_C = signal.SIGINT - if sys.platform == 'win32': - CTRL_C = signal.CTRL_C_EVENT - signal.signal(CTRL_C, lambda x, y: sys.exit(1)) - self._run_tests_pool = multiprocessing.Pool( - self.cpu_count, _capture_interrupt) + self._run_tests_pool = multiprocessing.Pool(self.cpu_count) # The local path of the currently-being-processed presubmit script. self._current_presubmit_path = os.path.dirname(presubmit_path) diff --git a/tests/presubmit_unittest.py b/tests/presubmit_unittest.py index e9192bb26..00aeb6414 100755 --- a/tests/presubmit_unittest.py +++ b/tests/presubmit_unittest.py @@ -165,8 +165,8 @@ class PresubmitUnittest(PresubmitTestsBase): 'git_footers', 'glob', 'inspect', 'json', 'load_files', 'logging', 'marshal', 'normpath', 'optparse', 'os', 'owners', 'owners_finder', 'pickle', 'presubmit_canned_checks', 'random', 're', 'rietveld', 'scm', - 'signal', 'subprocess', 'sys', 'tempfile', 'time', 'traceback', 'types', - 'unittest', 'urllib2', 'warn', 'multiprocessing', 'DoGetTryMasters', + 'subprocess', 'sys', 'tempfile', 'time', 'traceback', 'types', 'unittest', + 'urllib2', 'warn', 'multiprocessing', 'DoGetTryMasters', 'GetTryMastersExecuter', 'itertools', 'urlparse', 'gerrit_util', 'GerritAccessor', ]