Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Adds a do_stat option to CacheKeyGenerator, so that os.stat() doesn't…

… have to be used on production systems.
  • Loading branch information...
commit e43d08cc70717c0d61f9b3f95aee30bbe70d3d91 1 parent 5a626f0
@kurtiss authored
Showing with 8 additions and 2 deletions.
  1. +8 −2 shrapnel/caching.py
View
10 shrapnel/caching.py
@@ -105,7 +105,8 @@ def decorated(*args, **kwargs):
class CacheKeyGenerator(object):
- def __init__(self, *key_parts):
+ def __init__(self, *key_parts, **kwargs):
+ self._do_stat = kwargs.pop('do_stat', False)
self._file_names = []
self._file_parts = []
self._key_parts = key_parts
@@ -114,11 +115,16 @@ def __init__(self, *key_parts):
def add_files(self, files):
if files:
self._key = None
+
+ mtime = "nostat"
for f in files:
+ if self._do_stat:
+ mtime = os.stat(f).st_mtime
+
index = bisect.bisect(self._file_names, f)
self._file_names.insert(index, f)
- self._file_parts.insert(index + 1, "{0}:{1}".format(f, os.stat(f).st_mtime))
+ self._file_parts.insert(index + 1, "{0}:{1}".format(f, mtime))
@property
def key(self):
Please sign in to comment.
Something went wrong with that request. Please try again.