From f260180a76167042ef53ea9a6f99f50e3b591b92 Mon Sep 17 00:00:00 2001 From: Alok Saldanha Date: Wed, 5 Nov 2025 21:54:18 -0500 Subject: [PATCH] set default_item_source and start pruner thread --- cellxgene_gateway/gateway.py | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/cellxgene_gateway/gateway.py b/cellxgene_gateway/gateway.py index a5a22ae..d2c787c 100644 --- a/cellxgene_gateway/gateway.py +++ b/cellxgene_gateway/gateway.py @@ -92,8 +92,19 @@ def _init_on_first_wsgi_request(wsgi_app): global data_sources_initialized if not data_sources_initialized: with data_sources_init_lock: + if not app.launchtime: + app.launchtime = current_time_stamp() if not data_sources_initialized: initialize_data_sources() + + env.validate() + if not item_sources or not len(item_sources): + raise Exception("No data sources specified for Cellxgene Gateway") + + global default_item_source + if default_item_source is None: + default_item_source = item_sources[0] + data_sources_initialized = True return wsgi_app(environ, start_response) @@ -344,24 +355,20 @@ def ip_address(): resp = make_response(env.ip) return set_no_cache(resp) - -def launch(): - env.validate() - if not item_sources or not len(item_sources): - raise Exception("No data sources specified for Cellxgene Gateway") - - global default_item_source - if default_item_source is None: - default_item_source = item_sources[0] - +def start_pruner_thread(): pruner = PruneProcessCache(cache) background_thread = Thread(target=pruner) background_thread.start() + +def launch(): + start_pruner_thread() + app.launchtime = current_time_stamp() app.run(host="0.0.0.0", port=env.gateway_port, debug=False) +app.launchtime = None def main(): """CLI entry point for Flask development server."""