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

Unified Diff: tools/telemetry/telemetry/core/backends/chrome/android_browser_finder.py

Issue 407303003: Re-Reland: [Telemetry] Fix a flake in android browser finder. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/telemetry/telemetry/core/backends/chrome/android_browser_finder.py
diff --git a/tools/telemetry/telemetry/core/backends/chrome/android_browser_finder.py b/tools/telemetry/telemetry/core/backends/chrome/android_browser_finder.py
index 7c23ea4881b3aa646a43a7e97444dcdd228305ac..6491d2c2b2391fd43215b31a2a3df5db2605eb7c 100644
--- a/tools/telemetry/telemetry/core/backends/chrome/android_browser_finder.py
+++ b/tools/telemetry/telemetry/core/backends/chrome/android_browser_finder.py
@@ -20,6 +20,11 @@ from telemetry.core.backends.chrome import android_browser_backend
from telemetry.core.platform import android_platform_backend
from telemetry.core.platform.profiler import monsoon
+try:
+ import psutil # pylint: disable=F0401
+except ImportError:
+ psutil = None
+
CHROME_PACKAGE_NAMES = {
'android-content-shell':
@@ -232,19 +237,22 @@ Waiting for device...
# Ignore result.
adb.EnableAdbRoot()
- if sys.platform.startswith('linux'):
- # Host side workaround for crbug.com/268450 (adb instability)
+ if psutil:
+ # Host side workaround for crbug.com/268450 (adb instability).
# The adb server has a race which is mitigated by binding to a single core.
- import psutil # pylint: disable=F0401
- pids = [p.pid for p in psutil.process_iter() if 'adb' in p.name]
- with open(os.devnull, 'w') as devnull:
- for pid in pids:
- ret = subprocess.call(['taskset', '-p', '-c', '0', str(pid)],
- stdout=subprocess.PIPE,
- stderr=subprocess.PIPE,
- stdin=devnull)
- if ret:
- logging.warn('Failed to taskset %d (%s)', pid, ret)
+ for proc in psutil.process_iter():
+ try:
+ if 'adb' in proc.name:
+ if 'cpu_affinity' in dir(proc):
+ proc.cpu_affinity([0]) # New versions of psutil.
+ elif 'set_cpu_affinity' in dir(proc):
+ proc.set_cpu_affinity([0]) # Older versions.
+ else:
+ logging.warn(
+ 'Cannot set CPU affinity due to stale psutil version: %s',
+ '.'.join(psutil.version_info))
+ except (psutil.NoSuchProcess, psutil.AccessDenied):
+ logging.warn('Failed to set adb process CPU affinity')
if not os.environ.get('BUILDBOT_BUILDERNAME'):
# Killing adbd before running tests has proven to make them less likely to
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698