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

Unified Diff: build/android/pylib/device/device_utils.py

Issue 1254843002: telemetry: Fix killing the perf profiler (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Change GetPids instead. Created 5 years, 5 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: build/android/pylib/device/device_utils.py
diff --git a/build/android/pylib/device/device_utils.py b/build/android/pylib/device/device_utils.py
index f201ef36b8bf04fa20881109d11c6225f8322bfb..ba04cda4a2f1d7be2ed502533bbd65aedf69c2e8 100644
--- a/build/android/pylib/device/device_utils.py
+++ b/build/android/pylib/device/device_utils.py
@@ -736,7 +736,9 @@ class DeviceUtils(object):
CommandTimeoutError on timeout.
DeviceUnreachableError on missing device.
"""
- pids = self.GetPids(process_name)
+ pids = [pid
+ for pids in self.GetPids(process_name).values()
+ for pid in pids]
perezju 2015/07/27 09:56:32 maybe just me, but I think this would be somewhat
Sami 2015/07/27 11:37:00 Thanks, I went for a little less efficient but com
if not pids:
if quiet:
return 0
@@ -744,7 +746,7 @@ class DeviceUtils(object):
raise device_errors.CommandFailedError(
'No process "%s"' % process_name, str(self))
- cmd = ['kill', '-%d' % signum] + pids.values()
+ cmd = ['kill', '-%d' % signum] + pids
self.RunShellCommand(cmd, as_root=as_root, check_return=True)
if blocking:
@@ -1576,14 +1578,14 @@ class DeviceUtils(object):
retries: number of retries
Returns:
- A dict mapping process name to PID for each process that contained the
- provided |process_name|.
+ A dict mapping process name to a list of PIDs for each process that
+ contained the provided |process_name|.
Raises:
CommandTimeoutError on timeout.
DeviceUnreachableError on missing device.
"""
- procs_pids = {}
+ procs_pids = collections.defaultdict(list)
try:
ps_output = self._RunPipedShellCommand(
'ps | grep -F %s' % cmd_helper.SingleQuote(process_name))
@@ -1599,7 +1601,8 @@ class DeviceUtils(object):
try:
ps_data = line.split()
if process_name in ps_data[-1]:
- procs_pids[ps_data[-1]] = ps_data[1]
+ pid, process = ps_data[1], ps_data[-1]
+ procs_pids[process].append(pid)
except IndexError:
pass
return procs_pids

Powered by Google App Engine
This is Rietveld 408576698