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

Unified Diff: appengine/findit/waterfall/lock_util.py

Issue 1999653003: [Findit] Bailing out if build data is too old and moving relevant settings to config (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@master
Patch Set: Addressing comments Created 4 years, 7 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 | « appengine/findit/waterfall/build_util.py ('k') | appengine/findit/waterfall/test/build_util_test.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: appengine/findit/waterfall/lock_util.py
diff --git a/appengine/findit/waterfall/lock_util.py b/appengine/findit/waterfall/lock_util.py
index 381337c341fd14ed5ae712c73273a08a4071d54f..b4034571e8ba239f98358fad60d9d849e6bd9721 100644
--- a/appengine/findit/waterfall/lock_util.py
+++ b/appengine/findit/waterfall/lock_util.py
@@ -6,12 +6,12 @@ import logging
import random
import time
+from waterfall import waterfall_config
+
from google.appengine.api import memcache
_MEMCACHE_MASTER_DOWNLOAD_LOCK = 'master-download-lock-%s'
-_MEMCACHE_MASTER_DOWNLOAD_EXPIRATION_SECONDS = 60 * 60
-_DOWNLOAD_INTERVAL_SECONDS = 10
def WaitUntilDownloadAllowed(
@@ -24,20 +24,26 @@ def WaitUntilDownloadAllowed(
"""
client = memcache.Client()
key = _MEMCACHE_MASTER_DOWNLOAD_LOCK % master_name
-
deadline = time.time() + timeout_seconds
+ download_interval_seconds = (
+ waterfall_config.GetDownloadBuildDataSettings().get(
+ 'download_interval_seconds'))
+ memcache_master_download_expiration_seconds = (
+ waterfall_config.GetDownloadBuildDataSettings().get(
+ 'memcache_master_download_expiration_seconds'))
+
while True:
info = client.gets(key)
- if not info or time.time() - info['time'] >= _DOWNLOAD_INTERVAL_SECONDS:
+ if not info or time.time() - info['time'] >= download_interval_seconds:
new_info = {
'time': time.time()
}
if not info:
success = client.add(
- key, new_info, time=_MEMCACHE_MASTER_DOWNLOAD_EXPIRATION_SECONDS)
+ key, new_info, time=memcache_master_download_expiration_seconds)
else:
success = client.cas(
- key, new_info, time=_MEMCACHE_MASTER_DOWNLOAD_EXPIRATION_SECONDS)
+ key, new_info, time=memcache_master_download_expiration_seconds)
if success:
logging.info('Download from %s is allowed. Waited %s seconds.',
@@ -50,4 +56,4 @@ def WaitUntilDownloadAllowed(
return False
logging.info('Waiting to download from %s', master_name)
- time.sleep(_DOWNLOAD_INTERVAL_SECONDS + random.random())
+ time.sleep(download_interval_seconds + random.random())
« no previous file with comments | « appengine/findit/waterfall/build_util.py ('k') | appengine/findit/waterfall/test/build_util_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698