Permalink
Browse files

bug 685673: increase default sleep time in util/retry.py. r=catlee/rail

  • Loading branch information...
1 parent 70a09de commit 2e9be799e8a60879c9ca15c7bb9a20b87fe62658 @mozbhearsum mozbhearsum committed Sep 14, 2011
Showing with 6 additions and 5 deletions.
  1. +5 −4 lib/python/buildtools/test/test_util_retry.py
  2. +1 −1 lib/python/util/retry.py
View
9 lib/python/buildtools/test/test_util_retry.py
@@ -37,7 +37,7 @@ def setUp(self):
def testRetrySucceed(self):
# Will raise if anything goes wrong
- retry(_succeedOnSecondAttempt, attempts=2)
+ retry(_succeedOnSecondAttempt, attempts=2, sleeptime=0)
def testRetryFailWithoutCatching(self):
self.assertRaises(Exception, retry, _alwaysFail, exceptions=())
@@ -46,11 +46,12 @@ def testRetryFailEnsureRaisesLastException(self):
self.assertRaises(Exception, retry, _alwaysFail)
def testRetrySelectiveExceptionSucceed(self):
- retry(_raiseCustomException, attempts=2, retry_exceptions=(NewError,))
+ retry(_raiseCustomException, attempts=2, sleeptime=0,
+ retry_exceptions=(NewError,))
def testRetrySelectiveExceptionFail(self):
self.assertRaises(NewError, retry, _raiseCustomException, attempts=2,
- retry_exceptions=(OtherError,))
+ sleeptime=0, retry_exceptions=(OtherError,))
# TODO: figure out a way to test that the sleep actually happened
def testRetryWithSleep(self):
@@ -69,5 +70,5 @@ def testRetryReturns(self):
def testRetryCleanupIsCalled(self):
cleanup = mock.Mock()
- retry(_succeedOnSecondAttempt, cleanup=cleanup)
+ retry(_succeedOnSecondAttempt, cleanup=cleanup, sleeptime=0)
self.assertEquals(cleanup.call_count, 1)
View
2 lib/python/util/retry.py
@@ -3,7 +3,7 @@
import logging
log = logging.getLogger(__name__)
-def retry(action, attempts=5, sleeptime=0, retry_exceptions=(Exception,),
+def retry(action, attempts=5, sleeptime=60, retry_exceptions=(Exception,),
cleanup=None, args=(), kwargs={}):
"""Call `action' a maximum of `attempts' times until it succeeds,
defaulting to 5. `sleeptime' is the number of seconds to wait

0 comments on commit 2e9be79

Please sign in to comment.