Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: globals/get_browser_versions.py

Issue 5230369355857920: Issue 2432 - Ignore temporary issues when retrieving browser versions (Closed)
Patch Set: Created May 19, 2015, 1:49 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
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: globals/get_browser_versions.py
===================================================================
--- a/globals/get_browser_versions.py
+++ b/globals/get_browser_versions.py
@@ -5,6 +5,7 @@
import urllib2
import errno
import logging
+import time
from xml.dom import minidom
from jinja2 import contextfunction
@@ -180,13 +181,15 @@
persistent_cache = {}
cached_versions = persistent_cache.get(browser)
+ now = time.mktime(time.gmtime())
Wladimir Palant 2015/05/19 14:15:47 now = time.time()?
Sebastian Noack 2015/05/19 14:18:22 This would return local time.
Wladimir Palant 2015/05/19 14:20:39 I don't really see a problem with that. Wouldn't e
if exc_info:
if not cached_versions:
raise exc_info[0], exc_info[1], exc_info[2]
versions = cached_versions
- logging.warning('Failed to get %s versions, falling back to '
- 'cached versions', browser, exc_info=exc_info)
+ if now - versions['timestamp'] > 60*60*2:
+ logging.warning('Failed to get %s versions, falling back to '
+ 'cached versions', browser, exc_info=exc_info)
else:
# Determine previous version: If we recorded the version before and it
# changed since then, the old current version becomes the new previous
@@ -209,6 +212,7 @@
key=lambda ver: map(int, ver.split('.'))
)
+ versions['timestamp'] = int(now)
Wladimir Palant 2015/05/19 14:15:47 Nit: I don't see much point rounding the timestamp
Sebastian Noack 2015/05/19 14:18:22 Done.
persistent_cache[browser] = versions
file.seek(0)
json.dump(persistent_cache, file)
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld