Chromium Code Reviews| 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] |