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

Side by Side Diff: build/android/pylib/android_commands.py

Issue 19471007: [android] Retry data pushes that fail due to device busy. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 """Provides an interface to communicate with the device via the adb command. 5 """Provides an interface to communicate with the device via the adb command.
6 6
7 Assumes adb binary is currently on system path. 7 Assumes adb binary is currently on system path.
8 """ 8 """
9 9
10 import collections 10 import collections
(...skipping 765 matching lines...) Expand 10 before | Expand all | Expand 10 after
776 self._pushed_files.append(device_path) 776 self._pushed_files.append(device_path)
777 self._potential_push_size += size 777 self._potential_push_size += size
778 778
779 if self.CheckMd5Sum(local_path, device_path): 779 if self.CheckMd5Sum(local_path, device_path):
780 return 780 return
781 781
782 self._actual_push_size += size 782 self._actual_push_size += size
783 # They don't match, so remove everything first and then create it. 783 # They don't match, so remove everything first and then create it.
784 if os.path.isdir(local_path): 784 if os.path.isdir(local_path):
785 self.RunShellCommand('rm -r %s' % device_path, timeout_time=2 * 60) 785 self.RunShellCommand('rm -r %s' % device_path, timeout_time=2 * 60)
786 self.RunShellCommand('mkdir -p %s' % device_path) 786 self.RunShellCommand('mkdir -p %s' % device_path)
frankf 2013/07/18 17:54:07 Is this necessary? Doesn't push overwrite? From th
787 787
788 # NOTE: We can't use adb_interface.Push() because it hardcodes a timeout of 788 # NOTE: We can't use adb_interface.Push() because it hardcodes a timeout of
789 # 60 seconds which isn't sufficient for a lot of users of this method. 789 # 60 seconds which isn't sufficient for a lot of users of this method.
790 push_command = 'push %s %s' % (local_path, device_path) 790 push_command = 'push %s %s' % (local_path, device_path)
791 self._LogShell(push_command) 791 self._LogShell(push_command)
792 output = self._adb.SendCommand(push_command, timeout_time=30 * 60) 792
793 assert _HasAdbPushSucceeded(output) 793 # Retry push with increasing backoff if the device is busy.
794 retry = 0
795 while True:
796 output = self._adb.SendCommand(push_command, timeout_time=30 * 60)
797 if _HasAdbPushSucceeded(output):
798 return
799 if 'resource busy' in output and retry < 3:
frankf 2013/07/18 17:54:07 If rm is required, then shouldn't you also being d
800 retry += 1
801 wait_time = 5 * retry
802 logging.error('Push failed, retrying in %d seconds: %s' %
803 (wait_time, output))
804 time.sleep(wait_time)
805 else:
806 raise Exception('Push failed: %s' % output)
794 807
795 def GetPushSizeInfo(self): 808 def GetPushSizeInfo(self):
796 """Get total size of pushes to the device done via PushIfNeeded() 809 """Get total size of pushes to the device done via PushIfNeeded()
797 810
798 Returns: 811 Returns:
799 A tuple: 812 A tuple:
800 1. Total size of push requests to PushIfNeeded (MB) 813 1. Total size of push requests to PushIfNeeded (MB)
801 2. Total size that was actually pushed (MB) 814 2. Total size that was actually pushed (MB)
802 """ 815 """
803 return (self._potential_push_size, self._actual_push_size) 816 return (self._potential_push_size, self._actual_push_size)
(...skipping 587 matching lines...) Expand 10 before | Expand all | Expand 10 after
1391 """ 1404 """
1392 def __init__(self, output): 1405 def __init__(self, output):
1393 self._output = output 1406 self._output = output
1394 1407
1395 def write(self, data): 1408 def write(self, data):
1396 data = data.replace('\r\r\n', '\n') 1409 data = data.replace('\r\r\n', '\n')
1397 self._output.write(data) 1410 self._output.write(data)
1398 1411
1399 def flush(self): 1412 def flush(self):
1400 self._output.flush() 1413 self._output.flush()
OLDNEW
« 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