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

Side by Side Diff: testing/legion/host_controller.py

Issue 951673002: Revert "Pull chromium at 2c3ffb2355a27c32f45e508ef861416b820c823b" (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 10 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 | « testing/legion/examples/subprocess/task.isolate ('k') | testing/legion/legion.isolate » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 """Defines the host controller base library.
6
7 This module is the basis on which host controllers are built and executed.
8 """
9
10 import logging
11 import sys
12
13 #pylint: disable=relative-import
14 import client_lib
15 import common_lib
16 import discovery_server
17
18
19 class HostController(object):
20 """The base host controller class."""
21
22 def __init__(self):
23 self._discovery_server = discovery_server.DiscoveryServer()
24
25 def SetUp(self):
26 """Setup method used by the subclass."""
27 pass
28
29 def Task(self):
30 """Main task method used by the subclass."""
31 pass
32
33 def TearDown(self):
34 """Teardown method used by the subclass."""
35 pass
36
37 def NewClient(self, *args, **kwargs):
38 controller = client_lib.ClientController(*args, **kwargs)
39 self._discovery_server.RegisterClientCallback(
40 controller.otp, controller.OnConnect)
41 return controller
42
43 def RunController(self):
44 """Main entry point for the controller."""
45 print ' '.join(sys.argv)
46 common_lib.InitLogging()
47 self._discovery_server.Start()
48
49 error = None
50 tb = None
51 try:
52 self.SetUp()
53 self.Task()
54 except Exception as e:
55 # Defer raising exceptions until after TearDown and _TearDown are called.
56 error = e
57 tb = sys.exc_info()[-1]
58 try:
59 self.TearDown()
60 except Exception as e:
61 # Defer raising exceptions until after _TearDown is called.
62 # Note that an error raised here will obscure any errors raised
63 # previously.
64 error = e
65 tb = sys.exc_info()[-1]
66
67 self._discovery_server.Shutdown()
68 client_lib.ClientController.ReleaseAllControllers()
69 if error:
70 raise error, None, tb #pylint: disable=raising-bad-type
OLDNEW
« no previous file with comments | « testing/legion/examples/subprocess/task.isolate ('k') | testing/legion/legion.isolate » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698