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

Unified Diff: build/android/buildbot/bb_device_status_check.py

Issue 39833003: Android: kill all adb instances before trying to restart usb. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 2 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: build/android/buildbot/bb_device_status_check.py
diff --git a/build/android/buildbot/bb_device_status_check.py b/build/android/buildbot/bb_device_status_check.py
index e279b5095c32ee9b33f1f17d0927139d602f1cb9..b43ee0a99b9f189d3343639cdd8015bc4b9782a6 100755
--- a/build/android/buildbot/bb_device_status_check.py
+++ b/build/android/buildbot/bb_device_status_check.py
@@ -8,6 +8,8 @@
import logging
import optparse
import os
+import psutil
+import signal
import smtplib
import subprocess
import sys
@@ -241,6 +243,24 @@ def RestartUsb():
return 0
+def KillAllAdb():
+ def GetAllAdb():
+ for p in psutil.process_iter():
+ if 'adb' in p.name or 'adb' in ' '.join(p.cmdline):
+ yield p
+
+ for sig in [signal.SIGTERM, signal.SIGQUIT, signal.SIGKILL]:
+ for p in GetAllAdb():
+ try:
+ print 'kill %d %d (%s [%s])' % (sig, p.pid, p.name,
+ ' '.join(p.cmdline))
+ p.send_signal(sig)
+ except psutil.error.NoSuchProcess:
+ pass
+ for p in GetAllAdb():
+ print 'Unable to kill %d (%s [%s])' % (p.pid, p.name, ' '.join(p.cmdline))
+
+
def main():
parser = optparse.OptionParser()
parser.add_option('', '--out-dir',
@@ -257,6 +277,7 @@ def main():
parser.error('Unknown options %s' % args)
if options.restart_usb:
+ KillAllAdb()
rc = RestartUsb()
if rc:
return 1
« 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