Commit 2d6d868c authored by Alok Saldanha's avatar Alok Saldanha
Browse files

#9 only prune entries that have a pid

parent 91c96078
...@@ -13,7 +13,6 @@ import logging ...@@ -13,7 +13,6 @@ import logging
from cellxgene_gateway.util import current_time_stamp from cellxgene_gateway.util import current_time_stamp
from cellxgene_gateway.env import ttl from cellxgene_gateway.env import ttl
class PruneProcessCache: class PruneProcessCache:
def __init__(self, cache): def __init__(self, cache):
self.cache = cache self.cache = cache
...@@ -27,8 +26,10 @@ class PruneProcessCache: ...@@ -27,8 +26,10 @@ class PruneProcessCache:
def prune(self): def prune(self):
timestamp = current_time_stamp() timestamp = current_time_stamp()
cutoff = timestamp - self.expire_seconds cutoff = timestamp - self.expire_seconds
processes_to_delete = [p for p in self.cache.entry_list if p.timestamp < cutoff] def prunable(p):
processes_to_keep = [p for p in self.cache.entry_list if not p.timestamp < cutoff] return p.timestamp < cutoff and p.pid != None
processes_to_delete = [p for p in self.cache.entry_list if prunable(p)]
processes_to_keep = [p for p in self.cache.entry_list if not prunable(p)]
logger = logging.getLogger("cellxgene_gateway") logger = logging.getLogger("cellxgene_gateway")
logger.debug(f"Cutoff {cutoff} = timestamp {timestamp} - expire seconds {self.expire_seconds} , keeping {processes_to_keep}") logger.debug(f"Cutoff {cutoff} = timestamp {timestamp} - expire seconds {self.expire_seconds} , keeping {processes_to_keep}")
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment