fix: 重载时重复调用load_config()

This commit is contained in:
Rock Chin
2023-03-23 21:29:51 +08:00
parent 9fe4f218d5
commit b6e31cac23
2 changed files with 4 additions and 1 deletions

View File

@@ -102,6 +102,7 @@ def reset_logging():
pkg.utils.context.context['logger_handler'] = sh
return sh
# 临时函数用于加载config和上下文未来统一放在config类
def load_config():
# 完整性校验
@@ -121,13 +122,13 @@ def load_config():
# 存进上下文
pkg.utils.context.set_config(config)
def start(first_time_init=False):
"""启动流程reload之后会被执行"""
global known_exception_caught
import pkg.utils.context
load_config() #暂时在start里加载config应对重载未来在config抽象类中统一处理reload(未来删除该行)
config = pkg.utils.context.get_config()
# 更新openai库到最新版本
if not hasattr(config, 'upgrade_dependencies') or config.upgrade_dependencies:

View File

@@ -32,6 +32,7 @@ def reload_all(notify=True):
context.context['exceeded_keys'] = context.get_openai_manager().key_mgr.exceeded
this_context = context.context
walk(pkg)
importlib.reload(__import__("config-template"))
importlib.reload(__import__('config'))
importlib.reload(__import__('main'))
importlib.reload(__import__('banlist'))
@@ -43,6 +44,7 @@ def reload_all(notify=True):
# 执行启动流程
logging.info("执行程序启动流程")
main.load_config()
context.get_thread_ctl().reload(
admin_pool_num=context.get_config().admin_pool_num,
user_pool_num=context.get_config().user_pool_num