Commit 5254da18 authored by Aaron Gable's avatar Aaron Gable Committed by Commit Bot

Revert "Capture ctrl-c in presubmit multiprocessing pool"

This reverts commit 873c28d1.

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
> <ctrl>+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 <iannucci@chromium.org>
> Commit-Queue: Aaron Gable <agable@chromium.org>

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/653434Reviewed-by: 's avatarAaron Gable <agable@chromium.org>
Commit-Queue: Aaron Gable <agable@chromium.org>
parent ee3946be
...@@ -30,7 +30,6 @@ import os # Somewhat exposed through the API. ...@@ -30,7 +30,6 @@ import os # Somewhat exposed through the API.
import pickle # Exposed through the API. import pickle # Exposed through the API.
import random import random
import re # Exposed through the API. import re # Exposed through the API.
import signal
import sys # Parts exposed through API. import sys # Parts exposed through API.
import tempfile # Exposed through the API. import tempfile # Exposed through the API.
import time import time
...@@ -436,19 +435,11 @@ class InputApi(object): ...@@ -436,19 +435,11 @@ class InputApi(object):
self.cpu_count = multiprocessing.cpu_count() 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 # changed, which causes Pool() to explode fantastically when run on windows
# (because it tries to load the __main__ module, which imports lots of # (because it tries to load the __main__ module, which imports lots of
# things relative to the current working directory). # things relative to the current working directory).
# We capture ctrl-c in the initializer to prevent massive console spew when self._run_tests_pool = multiprocessing.Pool(self.cpu_count)
# 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)
# The local path of the currently-being-processed presubmit script. # The local path of the currently-being-processed presubmit script.
self._current_presubmit_path = os.path.dirname(presubmit_path) self._current_presubmit_path = os.path.dirname(presubmit_path)
......
...@@ -165,8 +165,8 @@ class PresubmitUnittest(PresubmitTestsBase): ...@@ -165,8 +165,8 @@ class PresubmitUnittest(PresubmitTestsBase):
'git_footers', 'glob', 'inspect', 'json', 'load_files', 'logging', 'git_footers', 'glob', 'inspect', 'json', 'load_files', 'logging',
'marshal', 'normpath', 'optparse', 'os', 'owners', 'owners_finder', 'marshal', 'normpath', 'optparse', 'os', 'owners', 'owners_finder',
'pickle', 'presubmit_canned_checks', 'random', 're', 'rietveld', 'scm', 'pickle', 'presubmit_canned_checks', 'random', 're', 'rietveld', 'scm',
'signal', 'subprocess', 'sys', 'tempfile', 'time', 'traceback', 'types', 'subprocess', 'sys', 'tempfile', 'time', 'traceback', 'types', 'unittest',
'unittest', 'urllib2', 'warn', 'multiprocessing', 'DoGetTryMasters', 'urllib2', 'warn', 'multiprocessing', 'DoGetTryMasters',
'GetTryMastersExecuter', 'itertools', 'urlparse', 'gerrit_util', 'GetTryMastersExecuter', 'itertools', 'urlparse', 'gerrit_util',
'GerritAccessor', 'GerritAccessor',
] ]
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment