Commit 2a16b95e authored by tandrii's avatar tandrii Committed by Commit bot

git cl: refactor direct usage of time.sleep and time.time.

R=machenbach@chromium.org

Review-Url: https://chromiumcodereview.appspot.com/2433813004
parent 6ff1fc0e
...@@ -23,7 +23,6 @@ import re ...@@ -23,7 +23,6 @@ import re
import stat import stat
import sys import sys
import textwrap import textwrap
import time
import traceback import traceback
import urllib import urllib
import urllib2 import urllib2
...@@ -148,6 +147,13 @@ def BranchExists(branch): ...@@ -148,6 +147,13 @@ def BranchExists(branch):
return not code return not code
def time_sleep(seconds):
# Use this so that it can be mocked in tests without interfering with python
# system machinery.
import time # Local import to discourage others from importing time globally.
return time.sleep(seconds)
def ask_for_data(prompt): def ask_for_data(prompt):
try: try:
return raw_input(prompt) return raw_input(prompt)
...@@ -313,7 +319,7 @@ def _buildbucket_retry(operation_name, http, *args, **kwargs): ...@@ -313,7 +319,7 @@ def _buildbucket_retry(operation_name, http, *args, **kwargs):
# status >= 500 means transient failures. # status >= 500 means transient failures.
logging.debug('Transient errors when %s. Will retry.', operation_name) logging.debug('Transient errors when %s. Will retry.', operation_name)
time.sleep(0.5 + 1.5*try_count) time_sleep(0.5 + 1.5*try_count)
try_count += 1 try_count += 1
assert False, 'unreachable' assert False, 'unreachable'
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment