Index: sitescripts/stats/bin/logprocessor.py |
=================================================================== |
--- a/sitescripts/stats/bin/logprocessor.py |
+++ b/sitescripts/stats/bin/logprocessor.py |
@@ -112,17 +112,21 @@ def cache_lru(func): |
if arg in results: |
result = results[arg] |
del results[arg] |
else: |
if results.entries_left > 0: |
results.entries_left -= 1 |
else: |
results.popitem(last=False) |
- result = func(arg) |
+ try: |
+ result = func(arg) |
+ except: |
Sebastian Noack
2015/10/21 15:19:20
You probably should explicitly catch Exception. Ot
Wladimir Palant
2015/10/21 15:42:40
Why shouldn't it? The exception is re-raised, the
Sebastian Noack
2015/10/21 15:49:13
Acknowledged.
|
+ results.entries_left += 1 |
+ raise |
results[arg] = result |
return result |
return wrapped |
def cache_last(func): |
""" |
Decorator that memoizes the last return value of a function in case it is |
@@ -262,16 +266,18 @@ def parse_path(path): |
return path[1:], urlparts.query |
@cache_lru |
def parse_query(query): |
return urlparse.parse_qs(query) |
@cache_lru |
def parse_lastversion(last_version): |
+ if '-' in last_version: |
+ last_version = last_version.split('-', 1)[0] |
Sebastian Noack
2015/10/21 15:19:20
Nit: last_version.split('-')[0] would do as will a
Wladimir Palant
2015/10/21 15:42:40
Sure, but the point is doing as little work as pos
Sebastian Noack
2015/10/21 15:49:13
More than one dash given is a rather theoretical s
Sebastian Noack
2015/10/21 16:10:34
I did some more benchmarking, and confirmed that t
Wladimir Palant
2015/10/21 16:16:03
No, it's a very real scenario if more than one not
Sebastian Noack
2015/10/21 16:19:51
Well, I'm not arguing. I just try to understand wh
|
return datetime.strptime(last_version, "%Y%m%d%H%M") |
@cache_lru |
def get_week(date): |
return date.isocalendar()[0:2] |
def parse_downloader_query(info): |
params = parse_query(info["query"]) |