Bug 1287496 - increment sleep timespan by (attempts * delay) seconds; r=ted draft
authorRob Thijssen <rthijssen@mozilla.com>
Mon, 18 Jul 2016 18:12:01 +0100
changeset 389115 ed884270604b106dbaccdb863f13221565e0d8ce
parent 389114 b9a0e0bb07886509b53a7c5066e1af3f99c049de
child 525661 c2201ac2ff9ee541d6d80aafa0da59f84f7f0360
push id23305
push userrthijssen@mozilla.com
push dateMon, 18 Jul 2016 17:14:00 +0000
reviewersted
bugs1287496
milestone50.0a1
Bug 1287496 - increment sleep timespan by (attempts * delay) seconds; r=ted MozReview-Commit-ID: Gx9fxp3xfZA
testing/mozbase/mozfile/mozfile/mozfile.py
--- a/testing/mozbase/mozfile/mozfile/mozfile.py
+++ b/testing/mozbase/mozfile/mozfile/mozfile.py
@@ -137,16 +137,18 @@ def rmtree(dir):
     return remove(dir)
 
 
 def _call_windows_retry(func, args=(), retry_max=5, retry_delay=0.5):
     """
     It's possible to see spurious errors on Windows due to various things
     keeping a handle to the directory open (explorer, virus scanners, etc)
     So we try a few times if it fails with a known error.
+    retry_delay is multiplied by the number of failed attempts to increase
+    the likelihood of success in subsequent attempts.
     """
     retry_count = 0
     while True:
         try:
             func(*args)
         except OSError as e:
             # Error codes are defined in:
             # http://docs.python.org/2/library/errno.html#module-errno
@@ -155,34 +157,34 @@ def _call_windows_retry(func, args=(), r
 
             if retry_count == retry_max:
                 raise
 
             retry_count += 1
 
             print '%s() failed for "%s". Reason: %s (%s). Retrying...' % \
                     (func.__name__, args, e.strerror, e.errno)
-            time.sleep(retry_delay)
+            time.sleep(retry_count * retry_delay)
         else:
             # If no exception has been thrown it should be done
             break
 
 
 def remove(path):
     """Removes the specified file, link, or directory tree.
 
     This is a replacement for shutil.rmtree that works better under
     windows. It does the following things:
 
      - check path access for the current user before trying to remove
      - retry operations on some known errors due to various things keeping
        a handle on file paths - like explorer, virus scanners, etc. The
        known errors are errno.EACCES and errno.ENOTEMPTY, and it will
-       retry up to 5 five times with a delay of 0.5 seconds between each
-       attempt.
+       retry up to 5 five times with a delay of (failed_attempts * 0.5) seconds
+       between each attempt.
 
     Note that no error will be raised if the given path does not exists.
 
     :param path: path to be removed
     """
 
     import shutil