mirror of
https://github.com/zhayujie/bot-on-anything.git
synced 2026-01-19 01:21:06 +08:00
docs: modify comment in app.py
This commit is contained in:
16
app.py
16
app.py
@@ -9,10 +9,10 @@ from multiprocessing import Pool
|
|||||||
from plugins.plugin_manager import PluginManager
|
from plugins.plugin_manager import PluginManager
|
||||||
|
|
||||||
|
|
||||||
# 启动通道
|
# Start channel
|
||||||
def start_process(channel_type, config_path):
|
def start_process(channel_type, config_path):
|
||||||
try:
|
try:
|
||||||
# 若为多进程启动,子进程无法直接访问主进程的内存空间,重新创建config类
|
# For multi-process startup, child processes cannot directly access parent process memory space, recreate config class
|
||||||
config.load_config(config_path)
|
config.load_config(config_path)
|
||||||
model_type = config.conf().get("model").get("type")
|
model_type = config.conf().get("model").get("type")
|
||||||
log.info("[MultiChannel] Start up {} on {}", model_type, channel_type)
|
log.info("[MultiChannel] Start up {} on {}", model_type, channel_type)
|
||||||
@@ -32,25 +32,25 @@ def main():
|
|||||||
channel_type = config.conf().get("channel").get("type")
|
channel_type = config.conf().get("channel").get("type")
|
||||||
|
|
||||||
PluginManager()
|
PluginManager()
|
||||||
# 1.单个字符串格式配置时,直接启动
|
# 1. For single string config format, start directly
|
||||||
if not isinstance(channel_type, list):
|
if not isinstance(channel_type, list):
|
||||||
start_process(channel_type, args.config)
|
start_process(channel_type, args.config)
|
||||||
exit(0)
|
exit(0)
|
||||||
|
|
||||||
# 2.单通道列表配置时,直接启动
|
# 2. For single channel list config, start directly
|
||||||
if len(channel_type) == 1:
|
if len(channel_type) == 1:
|
||||||
start_process(channel_type[0], args.config)
|
start_process(channel_type[0], args.config)
|
||||||
exit(0)
|
exit(0)
|
||||||
|
|
||||||
# 3.多通道配置时,进程池启动
|
# 3. For multi-channel config, start with process pool
|
||||||
# 使用主进程启动终端通道
|
# Use main process to start terminal channel
|
||||||
if const.TERMINAL in channel_type:
|
if const.TERMINAL in channel_type:
|
||||||
index = channel_type.index(const.TERMINAL)
|
index = channel_type.index(const.TERMINAL)
|
||||||
terminal = channel_type.pop(index)
|
terminal = channel_type.pop(index)
|
||||||
else:
|
else:
|
||||||
terminal = None
|
terminal = None
|
||||||
|
|
||||||
# 使用进程池启动其他通道子进程
|
# Use process pool to start other channel subprocesses
|
||||||
pool = Pool(len(channel_type))
|
pool = Pool(len(channel_type))
|
||||||
for type_item in channel_type:
|
for type_item in channel_type:
|
||||||
log.info("[INIT] Start up: {} on {}", model_type, type_item)
|
log.info("[INIT] Start up: {} on {}", model_type, type_item)
|
||||||
@@ -59,7 +59,7 @@ def main():
|
|||||||
if terminal:
|
if terminal:
|
||||||
start_process(terminal, args.config)
|
start_process(terminal, args.config)
|
||||||
|
|
||||||
# 等待池中所有进程执行完毕
|
# Wait for all processes in the pool to complete
|
||||||
pool.close()
|
pool.close()
|
||||||
pool.join()
|
pool.join()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
|||||||
Reference in New Issue
Block a user