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

Side by Side Diff: appengine/findit/lib/cache_decorator.py

Issue 2344443005: [Findit] Factoring the gitiles (etc) stuff out into its own directory (Closed)
Patch Set: reordering imports Created 4 years, 1 month 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 unified diff | Download patch
« no previous file with comments | « appengine/findit/lib/__init__.py ('k') | appengine/findit/lib/gitiles/__init__.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2015 The Chromium Authors. All rights reserved. 1 # Copyright 2015 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 # TODO(http://crbug.com/660466): We should try to break dependencies.
6
5 """This module provides a decorator to cache the results of a function. 7 """This module provides a decorator to cache the results of a function.
6 8
7 Examples: 9 Examples:
8 1. Decorate a function: 10 1. Decorate a function:
9 @cache_decorator.Cached() 11 @cache_decorator.Cached()
10 def Test(a): 12 def Test(a):
11 return a + a 13 return a + a
12 14
13 Test('a') 15 Test('a')
14 Test('a') # Returns the cached 'aa'. 16 Test('a') # Returns the cached 'aa'.
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 except Exception: # pragma: no cover. 221 except Exception: # pragma: no cover.
220 logging.exception( 222 logging.exception(
221 'Failed to cache data for function %s.%s, args=%s, kwargs=%s', 223 'Failed to cache data for function %s.%s, args=%s, kwargs=%s',
222 func.__module__, func.__name__, repr(args), repr(kwargs)) 224 func.__module__, func.__name__, repr(args), repr(kwargs))
223 225
224 return result 226 return result
225 227
226 return Wrapped 228 return Wrapped
227 229
228 return Decorator 230 return Decorator
OLDNEW
« no previous file with comments | « appengine/findit/lib/__init__.py ('k') | appengine/findit/lib/gitiles/__init__.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698