#4 added failing test for cache pruning

This commit is contained in:
Alok Saldanha
2019-09-19 12:02:24 -04:00
parent c4828d8be5
commit f6d10946c6
2 changed files with 40 additions and 11 deletions
+14 -11
View File
@@ -21,17 +21,20 @@ class PruneProcessCache:
def __call__(self):
while True:
time.sleep(60)
self.prune()
timestamp = current_time_stamp()
def prune(self):
timestamp = current_time_stamp()
processes_to_delete = []
for p in self.cache.entry_list:
if timestamp - p.timestamp > (3600 if ttl is None else ttl):
processes_to_delete.append(p)
processes_to_delete
processes_to_delete = []
for p in self.cache.entry_list:
if timestamp - p.timestamp > (3600 if ttl is None else ttl):
processes_to_delete.append(p)
processes_to_delete
for process in processes_to_delete:
try:
cache.prune(process)
except Exception:
logging.getLogger("werkzeug").exception("failed to prune process")
for process in processes_to_delete:
try:
cache.prune(process)
except Exception:
logging.getLogger("werkzeug").exception("failed to prune process")