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

Unified Diff: tools/telemetry/telemetry/core/platform/android_platform_backend.py

Issue 820603002: [Telemetry] Make psutil use the new external_modules helper. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years 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 | tools/telemetry/telemetry/util/external_modules.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/telemetry/telemetry/core/platform/android_platform_backend.py
diff --git a/tools/telemetry/telemetry/core/platform/android_platform_backend.py b/tools/telemetry/telemetry/core/platform/android_platform_backend.py
index 93e0cc0a14f3e5761b3bd258c883b4fac55bb725..1075cb85fa879550132426caffc1a51bb090771a 100644
--- a/tools/telemetry/telemetry/core/platform/android_platform_backend.py
+++ b/tools/telemetry/telemetry/core/platform/android_platform_backend.py
@@ -26,7 +26,9 @@ from telemetry.core.platform.power_monitor import power_monitor_controller
from telemetry.core.platform.profiler import android_prebuilt_profiler_helper
from telemetry.timeline import surface_flinger_timeline_data
from telemetry.util import exception_formatter
+from telemetry.util import external_modules
+psutil = external_modules.ImportOptionalModule('psutil')
util.AddDirToPythonPath(util.GetChromiumSrcDir(),
'third_party', 'webpagereplay')
import adb_install_cert # pylint: disable=F0401
@@ -45,11 +47,6 @@ try:
except Exception:
surface_stats_collector = None
-try:
- import psutil # pylint: disable=import-error
-except ImportError:
- psutil = None
-
class AndroidPlatformBackend(
linux_based_platform_backend.LinuxBasedPlatformBackend):
@@ -605,13 +602,9 @@ def _FixPossibleAdbInstability():
for process in psutil.process_iter():
try:
if 'adb' in process.name:
- if 'cpu_affinity' in dir(process):
- process.cpu_affinity([0]) # New versions of psutil.
- elif 'set_cpu_affinity' in dir(process):
+ if 'set_cpu_affinity' in dir(process):
process.set_cpu_affinity([0]) # Older versions.
else:
- logging.warn(
- 'Cannot set CPU affinity due to stale psutil version: %s',
- '.'.join(str(x) for x in psutil.version_info))
+ process.cpu_affinity([0]) # New versions of psutil.
except (psutil.NoSuchProcess, psutil.AccessDenied):
logging.warn('Failed to set adb process CPU affinity')
« no previous file with comments | « no previous file | tools/telemetry/telemetry/util/external_modules.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698