mirror of
https://github.com/Novartis/cellxgene-gateway.git
synced 2026-09-17 22:07:57 +08:00
Compare commits
1 Commits
patch-item
...
prune_pid
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2d6d868c92 |
@@ -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:
|
|||||||
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}")
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user