mirror of
https://github.com/xinnan-tech/xiaozhi-esp32-server.git
synced 2026-11-27 04:49:47 +01:00
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:
parent
6086ca1e18
commit
bdf184db01
2 changed files with 9 additions and 4 deletions
|
|
@ -46,10 +46,15 @@ def formatter(record):
|
||||||
return record["message"]
|
return record["message"]
|
||||||
|
|
||||||
|
|
||||||
def setup_logging():
|
def setup_logging(config=None):
|
||||||
check_config_file()
|
|
||||||
"""Read log configuration from config file and set log output format and level"""
|
"""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"]
|
log_config = config["log"]
|
||||||
global _logger_initialized
|
global _logger_initialized
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ def check_config_file():
|
||||||
)
|
)
|
||||||
|
|
||||||
# Check if reading configuration from API
|
# Check if reading configuration from API
|
||||||
config = load_config()
|
config = asyncio.run(load_config())
|
||||||
if config.get("read_config_from_api", False):
|
if config.get("read_config_from_api", False):
|
||||||
print("Reading configuration from API")
|
print("Reading configuration from API")
|
||||||
old_config_origin = read_config(custom_config_file)
|
old_config_origin = read_config(custom_config_file)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue