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

Unified Diff: infra/libs/process_invocation/test/multiprocess_test.py

Issue 1130063003: Convert master_manager_launcher to use multiprocessing. (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@master-kickoff
Patch Set: Rebase onto latest master. Created 5 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « infra/libs/process_invocation/test/__init__.py ('k') | infra/services/master_manager_launcher/__main__.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: infra/libs/process_invocation/test/multiprocess_test.py
diff --git a/infra/libs/process_invocation/test/multiprocess_test.py b/infra/libs/process_invocation/test/multiprocess_test.py
new file mode 100644
index 0000000000000000000000000000000000000000..eb2503946a2026a3d6d28cc45d315fb747ce310c
--- /dev/null
+++ b/infra/libs/process_invocation/test/multiprocess_test.py
@@ -0,0 +1,48 @@
+# Copyright 2015 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+import multiprocessing
+from testing_support import auto_stub
+
+from infra.libs.process_invocation import multiprocess
+
+
+class TestMultiprocess(auto_stub.TestCase):
+ def setUp(self):
+ super(TestMultiprocess, self).setUp()
+
+ self.calls = set()
+ class FakePool(object):
+ def __init__(self, calls):
+ self.calls = calls
+
+ def close(self):
+ self.calls.add('close')
+
+ def terminate(self):
+ self.calls.add('terminate')
+
+ def join(self):
+ self.calls.add('join')
+
+ def pool_maker(*_args, **_kwargs):
+ return FakePool(self.calls)
+
+ self.mock(multiprocessing, 'Pool', pool_maker)
+
+ def testMultiprocess(self):
+ with multiprocess.MultiPool(16) as _pool:
+ pass
+
+ self.assertIn('close', self.calls)
+ self.assertIn('join', self.calls)
+ self.assertNotIn('terminate', self.calls)
+
+ def testMultiprocessTermiantes(self):
+ with self.assertRaises(RuntimeError):
+ with multiprocess.MultiPool(16) as _pool:
+ raise RuntimeError('a super bad error')
+
+ self.assertIn('terminate', self.calls)
+ self.assertIn('join', self.calls)
« no previous file with comments | « infra/libs/process_invocation/test/__init__.py ('k') | infra/services/master_manager_launcher/__main__.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698