提交 60445cf3 authored 作者: Frederic Bastien's avatar Frederic Bastien

wait 1 week before we remove the unversionned directory of old compilation.

This will remove most of the error message that was changed today for a warning.
上级 9394b5e2
...@@ -455,7 +455,9 @@ class ModuleCache(object): ...@@ -455,7 +455,9 @@ class ModuleCache(object):
#debug('stats', self.stats, sum(self.stats)) #debug('stats', self.stats, sum(self.stats))
return rval return rval
age_thresh_del = 60*60*24*31 age_thresh_del = 60*60*24*31#31 days
age_thresh_del_unversionned = 60*60*24*7#7 days
"""The default age threshold for `clear_old` (in seconds) """The default age threshold for `clear_old` (in seconds)
""" """
def clear_old(self, age_thresh_del=None): #default to a 31-day age_thresh_delold def clear_old(self, age_thresh_del=None): #default to a 31-day age_thresh_delold
...@@ -519,7 +521,8 @@ class ModuleCache(object): ...@@ -519,7 +521,8 @@ class ModuleCache(object):
assert parent.startswith(os.path.join(self.dirname, 'tmp')) assert parent.startswith(os.path.join(self.dirname, 'tmp'))
info("clear_unversioned removing cache dir", parent) info("clear_unversioned removing cache dir", parent)
_rmtree(parent) _rmtree(parent)
time_now = time.time()
for filename in os.listdir(self.dirname): for filename in os.listdir(self.dirname):
if filename.startswith('tmp'): if filename.startswith('tmp'):
try: try:
...@@ -528,13 +531,15 @@ class ModuleCache(object): ...@@ -528,13 +531,15 @@ class ModuleCache(object):
except IOError: except IOError:
has_key = False has_key = False
if not has_key: if not has_key:
#TODO: Remove this, or at least wait one week age = time_now - last_access_time(os.path.join(self.dirname, filename))
# This cache dir is either in use by another process #In normal case, the processus that created this directory will delete it
# (in that case, it will be removed by the code above), #In case this processus crash, it won't be cleaned up.
# or a remnant of a crashed process, in that case, it will #As we don't know how to know if this directory is still used
# be removed by clear_old at some point. #we wait 1 weak and suppose that the processus crashed
info("clear_unversioned removing cache dir", filename) #and we do the clean up for it.
_rmtree(os.path.join(self.dirname, filename)) if age > self.age_thresh_del_unversionned:
info("clear_unversioned removing cache dir", filename)
_rmtree(os.path.join(self.dirname, filename))
def _on_atexit(self): def _on_atexit(self):
self.refresh() self.refresh()
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论