fixed unit tests

This commit is contained in:
Alok Saldanha
2021-02-13 17:30:21 -05:00
parent d3ee04b6e5
commit 893092f199
2 changed files with 18 additions and 10 deletions
+8 -6
View File
@@ -10,14 +10,16 @@
import logging
import time
from cellxgene_gateway.env import ttl
from cellxgene_gateway.util import current_time_stamp
from cellxgene_gateway import env
from cellxgene_gateway import util
logger = logging.getLogger(__name__)
class PruneProcessCache:
def __init__(self, cache):
self.cache = cache
self.expire_seconds = 3600 if ttl is None else int(ttl)
self.expire_seconds = 3600 if env.ttl is None else int(env.ttl)
def __call__(self):
while True:
@@ -25,7 +27,7 @@ class PruneProcessCache:
self.prune()
def prune(self):
timestamp = current_time_stamp()
timestamp = util.current_time_stamp()
cutoff = timestamp - self.expire_seconds
processes_to_delete = [
p for p in self.cache.entry_list if p.timestamp < cutoff
@@ -33,9 +35,9 @@ class PruneProcessCache:
processes_to_keep = [
p for p in self.cache.entry_list if not p.timestamp < cutoff
]
logger = logging.getLogger("cellxgene_gateway")
logger.debug(
f"Cutoff {cutoff} = timestamp {timestamp} - expire seconds {self.expire_seconds} , keeping {processes_to_keep}"
f"Cutoff {cutoff} = timestamp {timestamp} - expire seconds {self.expire_seconds} , keeping {processes_to_keep}, pruning {processes_to_delete}"
)
for process in processes_to_delete: