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

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

Issue 890773003: Adding the initial code for Omnibot multi-machine support (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Changed the OTP format to be more descriptive 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
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 client RPC methods."""
6
7 import logging
8 import subprocess
9 import threading
10
11
12 class RPCMethods(object):
13 """Class exposing RPC methods."""
14
15 def __init__(self, server):
16 self.server = server
17
18 def Echo(self, message):
19 """Simple RPC method to print and return a message."""
20 logging.info('Echoing %s', message)
21 return 'echo ' + message
M-A Ruel 2015/02/03 18:50:24 I'd recommend return 'echo %s' % message in case s
Mike Meade 2015/02/03 19:06:28 Done.
22
23 def Subprocess(self, cmd):
24 """Run the commands in a subprocess.
25
26 Returns:
27 (returncode, stdout, stderr).
28 """
29 p = subprocess.Popen(cmd, stdout=subprocess.PIPE,
30 stderr=subprocess.PIPE)
31 stdout, stderr = p.communicate()
32 return (p.returncode, stdout, stderr)
33
34 def Quit(self):
35 """Call server.shutdown in another thread.
36
37 This is needed because server.shutdown waits for the server to actually
38 quit. However the server cannot shutdown until it completes handling this
39 call. Calling this in the same thread results in a deadlock.
40 """
41 t = threading.Thread(target=self.server.shutdown)
42 t.start()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698