async auto load plugin

This commit is contained in:
yhjun1026 2023-06-14 21:46:30 +08:00
parent d784e7e00a
commit 8ba409f305
2 changed files with 3 additions and 4 deletions

View File

@ -79,8 +79,7 @@ def load_native_plugins(cfg: Config):
print("not auto load_native_plugins") print("not auto load_native_plugins")
return return
def load_from_git(cfg: Config): def load_from_git(cfg: Config):
print("load_native_plugins") print("async load_native_plugins")
### TODO 默认拉主分支,后续拉发布版本
branch_name = cfg.plugins_git_branch branch_name = cfg.plugins_git_branch
native_plugin_repo = "DB-GPT-Plugins" native_plugin_repo = "DB-GPT-Plugins"
url = "https://github.com/csunny/{repo}/archive/{branch}.zip" url = "https://github.com/csunny/{repo}/archive/{branch}.zip"
@ -98,10 +97,10 @@ def load_native_plugins(cfg: Config):
print(file_name) print(file_name)
with open(file_name, "wb") as f: with open(file_name, "wb") as f:
f.write(response.content) f.write(response.content)
print("文件已保存到本地") print("save file")
cfg.set_plugins(scan_plugins(cfg, cfg.debug_mode)) cfg.set_plugins(scan_plugins(cfg, cfg.debug_mode))
else: else:
print("获取Release信息失败状态码为", response.status_code) print("get file faildresponse code", response.status_code)
# 创建一个线程 # 创建一个线程
t = threading.Thread(target=load_from_git, args=(cfg,)) t = threading.Thread(target=load_from_git, args=(cfg,))