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

Unified Diff: git_cl.py

Issue 2433813004: git cl: refactor direct usage of time.sleep and time.time. (Closed)
Patch Set: Created 4 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: git_cl.py
diff --git a/git_cl.py b/git_cl.py
index d8b90046c27dafb7ca4cf4e15d830c9754450290..18dc963407d46321b7f77937af2f9ed1de3fcfeb 100755
--- a/git_cl.py
+++ b/git_cl.py
@@ -23,7 +23,6 @@ import re
import stat
import sys
import textwrap
-import time
import traceback
import urllib
import urllib2
@@ -148,6 +147,13 @@ def BranchExists(branch):
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):
try:
return raw_input(prompt)
@@ -313,7 +319,7 @@ def _buildbucket_retry(operation_name, http, *args, **kwargs):
# status >= 500 means transient failures.
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
assert False, 'unreachable'
« 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