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

Side by Side 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 unified diff | Download patch
OLDNEW
(Empty)
1 # Copyright 2015 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
4
5 import multiprocessing
6 from testing_support import auto_stub
7
8 from infra.libs.process_invocation import multiprocess
9
10
11 class TestMultiprocess(auto_stub.TestCase):
12 def setUp(self):
13 super(TestMultiprocess, self).setUp()
14
15 self.calls = set()
16 class FakePool(object):
17 def __init__(self, calls):
18 self.calls = calls
19
20 def close(self):
21 self.calls.add('close')
22
23 def terminate(self):
24 self.calls.add('terminate')
25
26 def join(self):
27 self.calls.add('join')
28
29 def pool_maker(*_args, **_kwargs):
30 return FakePool(self.calls)
31
32 self.mock(multiprocessing, 'Pool', pool_maker)
33
34 def testMultiprocess(self):
35 with multiprocess.MultiPool(16) as _pool:
36 pass
37
38 self.assertIn('close', self.calls)
39 self.assertIn('join', self.calls)
40 self.assertNotIn('terminate', self.calls)
41
42 def testMultiprocessTermiantes(self):
43 with self.assertRaises(RuntimeError):
44 with multiprocess.MultiPool(16) as _pool:
45 raise RuntimeError('a super bad error')
46
47 self.assertIn('terminate', self.calls)
48 self.assertIn('join', self.calls)
OLDNEW
« 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