fix(server): restore upstream config-load deadlock fix lost in rebase

check_config_file() must drive the coroutine with asyncio.run(), and
setup_logging() must accept an already-loaded config (or hit the cache)
instead of re-entering the event loop from a running loop.
This commit is contained in:
lapy 2026-10-11 17:57:56 +01:00
parent 6086ca1e18
commit bdf184db01
2 changed files with 9 additions and 4 deletions

View file

@ -46,10 +46,15 @@ def formatter(record):
return record["message"]
def setup_logging():
check_config_file()
def setup_logging(config=None):
"""Read log configuration from config file and set log output format and level"""
config = load_config()
if config is None:
check_config_file()
# Check the cache first to avoid re-awaiting load_config in an async context
config = cache_manager.get(CacheType.CONFIG, "main_config")
if config is None:
# Cache also empty (should not happen in theory); only then run asyncio
config = asyncio.run(load_config())
log_config = config["log"]
global _logger_initialized

View file

@ -21,7 +21,7 @@ def check_config_file():
)
# Check if reading configuration from API
config = load_config()
config = asyncio.run(load_config())
if config.get("read_config_from_api", False):
print("Reading configuration from API")
old_config_origin = read_config(custom_config_file)