Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(504)

Side by Side Diff: presubmit_support.py

Issue 2296723006: Shutdown multiprocess pool after running tests to avoid _finalizer spew on Windows (Closed)
Patch Set: mock something something Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | tests/presubmit_unittest.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 """Enables directory-specific presubmit checks to run at upload and/or commit. 6 """Enables directory-specific presubmit checks to run at upload and/or commit.
7 """ 7 """
8 8
9 __version__ = '1.8.0' 9 __version__ = '1.8.0'
10 10
(...skipping 545 matching lines...) Expand 10 before | Expand all | Expand 10 after
556 tests.append(t) 556 tests.append(t)
557 if self.verbose: 557 if self.verbose:
558 t.info = _PresubmitNotifyResult 558 t.info = _PresubmitNotifyResult
559 if len(tests) > 1 and parallel: 559 if len(tests) > 1 and parallel:
560 # async recipe works around multiprocessing bug handling Ctrl-C 560 # async recipe works around multiprocessing bug handling Ctrl-C
561 msgs.extend(self._run_tests_pool.map_async(CallCommand, tests).get(99999)) 561 msgs.extend(self._run_tests_pool.map_async(CallCommand, tests).get(99999))
562 else: 562 else:
563 msgs.extend(map(CallCommand, tests)) 563 msgs.extend(map(CallCommand, tests))
564 return [m for m in msgs if m] 564 return [m for m in msgs if m]
565 565
566 def ShutdownPool(self):
567 self._run_tests_pool.close()
568 self._run_tests_pool.join()
569 self._run_tests_pool = None
570
566 571
567 class _DiffCache(object): 572 class _DiffCache(object):
568 """Caches diffs retrieved from a particular SCM.""" 573 """Caches diffs retrieved from a particular SCM."""
569 def __init__(self, upstream=None): 574 def __init__(self, upstream=None):
570 """Stores the upstream revision against which all diffs will be computed.""" 575 """Stores the upstream revision against which all diffs will be computed."""
571 self._upstream = upstream 576 self._upstream = upstream
572 577
573 def GetDiff(self, path, local_root): 578 def GetDiff(self, path, local_root):
574 """Get the diff for a particular path.""" 579 """Get the diff for a particular path."""
575 raise NotImplementedError() 580 raise NotImplementedError()
(...skipping 865 matching lines...) Expand 10 before | Expand all | Expand 10 after
1441 raise PresubmitFailure( 1446 raise PresubmitFailure(
1442 'Presubmit functions must return a tuple or list') 1447 'Presubmit functions must return a tuple or list')
1443 for item in result: 1448 for item in result:
1444 if not isinstance(item, OutputApi.PresubmitResult): 1449 if not isinstance(item, OutputApi.PresubmitResult):
1445 raise PresubmitFailure( 1450 raise PresubmitFailure(
1446 'All presubmit results must be of types derived from ' 1451 'All presubmit results must be of types derived from '
1447 'output_api.PresubmitResult') 1452 'output_api.PresubmitResult')
1448 else: 1453 else:
1449 result = () # no error since the script doesn't care about current event. 1454 result = () # no error since the script doesn't care about current event.
1450 1455
1456 input_api.ShutdownPool()
1457
1451 # Return the process to the original working directory. 1458 # Return the process to the original working directory.
1452 os.chdir(main_path) 1459 os.chdir(main_path)
1453 return result 1460 return result
1454 1461
1455 1462
1456 def DoPresubmitChecks(change, 1463 def DoPresubmitChecks(change,
1457 committing, 1464 committing,
1458 verbose, 1465 verbose,
1459 output_stream, 1466 output_stream,
1460 input_stream, 1467 input_stream,
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after
1799 return 2 1806 return 2
1800 1807
1801 1808
1802 if __name__ == '__main__': 1809 if __name__ == '__main__':
1803 fix_encoding.fix_encoding() 1810 fix_encoding.fix_encoding()
1804 try: 1811 try:
1805 sys.exit(main()) 1812 sys.exit(main())
1806 except KeyboardInterrupt: 1813 except KeyboardInterrupt:
1807 sys.stderr.write('interrupted\n') 1814 sys.stderr.write('interrupted\n')
1808 sys.exit(2) 1815 sys.exit(2)
OLDNEW
« no previous file with comments | « no previous file | tests/presubmit_unittest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698