diff options
author | yongsheng.zhu@intel.com <yongsheng.zhu@intel.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-09-10 04:55:27 +0000 |
---|---|---|
committer | yongsheng.zhu@intel.com <yongsheng.zhu@intel.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-09-10 04:55:27 +0000 |
commit | 9b280302bfed3ccd4a0dc412e06bd9c21ea22147 (patch) | |
tree | fb3d294c9ff996ade3a3a30ffc00c493e4e9bf0f /build | |
parent | 75ce66767743ece7f47c8fa5eff499015fb0a671 (diff) | |
download | chromium_src-9b280302bfed3ccd4a0dc412e06bd9c21ea22147.zip chromium_src-9b280302bfed3ccd4a0dc412e06bd9c21ea22147.tar.gz chromium_src-9b280302bfed3ccd4a0dc412e06bd9c21ea22147.tar.bz2 |
Fix 2 issues to workaround python bugs
1. The pool worker will hang though it calls sys.exit. So it and its parent
process can't exit.
2. Don't use multiprocessing.pool.map for there is a bug in python
which can't handle KeyInterrupt exception during the waiting. See here:
http://stackoverflow.com/questions/1408356/keyboard-interrupts-with-
pythons-multiprocessing-pool
BUG=
TEST=run_tests.py
Review URL: https://chromiumcodereview.appspot.com/10909110
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@155661 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'build')
-rw-r--r-- | build/android/pylib/base_test_sharder.py | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/build/android/pylib/base_test_sharder.py b/build/android/pylib/base_test_sharder.py index ade44e5..48206c2 100644 --- a/build/android/pylib/base_test_sharder.py +++ b/build/android/pylib/base_test_sharder.py @@ -16,8 +16,11 @@ def _ShardedTestRunnable(test): logging.getLogger().handlers[0].setFormatter(logging.Formatter(log_format)) else: logging.basicConfig(format=log_format) - return test.Run() - + # Handle SystemExit here since python has a bug to exit current process + try: + return test.Run() + except SystemExit: + return TestResults() def SetTestsContainer(tests_container): """Sets tests container. @@ -89,7 +92,10 @@ class BaseTestSharder(object): pool = multiprocessing.Pool(len(self.attached_devices), SetTestsContainer, [BaseTestSharder.tests_container]) - results_lists = pool.map(_ShardedTestRunnable, test_runners) + # map can't handle KeyboardInterrupt exception. It's a python bug. + # So use map_async instead. + async_results = pool.map_async(_ShardedTestRunnable, test_runners) + results_lists = async_results.get(999999) test_results = TestResults.FromTestResults(results_lists) if retry == self.retries - 1: all_passed = final_results.ok + test_results.ok |