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

Unified 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: Addressing initial comments Created 5 years, 11 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
Index: testing/legion/client_rpc_methods.py
diff --git a/testing/legion/client_rpc_methods.py b/testing/legion/client_rpc_methods.py
new file mode 100644
index 0000000000000000000000000000000000000000..2f99269e4a56087ee6195cc776e554f1aa858164
--- /dev/null
+++ b/testing/legion/client_rpc_methods.py
@@ -0,0 +1,49 @@
+# 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.
+"""Client RPC Methods.
Marc-Antoine Ruel (Google) 2015/01/30 21:58:39 This is not informative. "client_rpc_methods.py" p
Mike Meade 2015/02/03 01:18:08 Done.
+
+The RPC methods made available on the client are all defined here in the
+RPCMethods class. This class is made separate for easy maintenance and
+method lookup.
+"""
+
+import logging
+import subprocess
+import threading
+
+
+class RPCMethods(object):
+ """The class exposing RPC methods."""
+
+ def __init__(self, server):
+ self.server = server
+
+ def Echo(self, message):
+ """Simple RPC method to print and return a message."""
+ logging.info('Echoing %s', message)
+ return 'echo ' + message
+
+ def Subprocess(self, cmd):
+ """Run the commands in a subprocess.
+
+ Note that stdout and stderr are passed to this process' stdout and stderr
+ and only the return code is returned.
+
+ Args:
+ cmd: A command list to pass to subprocess.call.
+ """
+ p = subprocess.Popen(cmd, stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE)
+ p.wait()
Marc-Antoine Ruel (Google) 2015/01/30 21:58:39 This will hang. You need to use .communicate()
Mike Meade 2015/02/03 01:18:08 Done.
+ return (p.returncode, p.stdout.read(), p.stderr.read())
+
+ def Quit(self):
+ """Call server.shutdown in another thread.
+
+ This is needed because server.shutdown waits for the server to actually
+ quit. However the server cannot shutdown until it completes handling this
+ call. Calling this in the same thread results in a deadlock.
+ """
+ t = threading.Thread(target=self.server.shutdown)
+ t.start()

Powered by Google App Engine
This is Rietveld 408576698