mirror of
https://github.com/Novartis/cellxgene-gateway.git
synced 2026-10-07 11:48:12 +08:00
fixed unit tests
This commit is contained in:
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user