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) |