return max(max(os.path.getmtime(filename) for filename in list_files()),
os.path.getmtime(src_dirpath))
return max(max(os.path.getmtime(filename) for filename in list_files()),
os.path.getmtime(src_dirpath))
"""
Try loading the configuration from the faster-to-load JSON cache at
cache_path. If it doesn't exist or is outdated, load the configuration
"""
Try loading the configuration from the faster-to-load JSON cache at
cache_path. If it doesn't exist or is outdated, load the configuration
- try: cache_mtime = os.path.getmtime(cache_path)
- except OSError: do_refresh = True
- else: do_refresh = src_mtime + 1 >= cache_mtime
+ try:
+ cache_mtime = os.path.getmtime(cache_path)
+ except OSError:
+ do_refresh = True
+ else:
+ do_refresh = src_mtime + 1 >= cache_mtime
# (changing) version of the data (but the transaction can share the
# lock with other concurrent reads). This isolation is accomplished
# using an atomic filesystem rename in the refreshing stage.
# (changing) version of the data (but the transaction can share the
# lock with other concurrent reads). This isolation is accomplished
# using an atomic filesystem rename in the refreshing stage.
with open(cache_path + '.tmp', 'w') as f:
f.write(json.write(ns.cfg))
with open(cache_path + '.tmp', 'w') as f:
f.write(json.write(ns.cfg))