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

Unified Diff: tools/telemetry/telemetry/decorators.py

Issue 419973004: decorators.Cache Attach an unique id to objects (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 5 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: tools/telemetry/telemetry/decorators.py
diff --git a/tools/telemetry/telemetry/decorators.py b/tools/telemetry/telemetry/decorators.py
index 228c987ddf539bdb58096561e4acf588fcff91dd..12cdc1646af8e2e86f05f0279d693a0607f2c850 100644
--- a/tools/telemetry/telemetry/decorators.py
+++ b/tools/telemetry/telemetry/decorators.py
@@ -4,6 +4,7 @@
import functools
import types
+import uuid
def Cache(obj):
@@ -22,6 +23,18 @@ def Cache(obj):
@functools.wraps(obj)
def Cacher(*args, **kwargs):
key = str(args) + str(kwargs)
+
+ if len(args) > 0:
+ self = args[0]
+ if not hasattr(self, '__CacheUniqueId'):
+ try:
+ self.__CacheUniqueId = uuid.uuid4().hex
tonyg 2014/07/25 21:13:55 Thanks for digging into this!! Looking again at t
+ except AttributeError:
+ pass
+
+ if hasattr(self, '__CacheUniqueId'):
+ key = self.__CacheUniqueId + key
+
if key not in cache:
cache[key] = obj(*args, **kwargs)
return cache[key]
« 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