mirror of
https://github.com/Genshin-bots/gsuid_core.git
synced 2025-06-09 08:59:42 +08:00
🐛 修复导入Bug
This commit is contained in:
parent
d5c2ebb878
commit
331102560d
@ -1,4 +1,3 @@
|
||||
import os
|
||||
import re
|
||||
import sys
|
||||
import time
|
||||
@ -8,7 +7,6 @@ import subprocess
|
||||
import importlib.util
|
||||
from pathlib import Path
|
||||
from types import ModuleType
|
||||
from concurrent.futures import ThreadPoolExecutor
|
||||
from typing import Dict, List, Tuple, Union, Callable
|
||||
|
||||
import toml
|
||||
@ -214,6 +212,16 @@ class GsServer:
|
||||
continue
|
||||
all_plugins.extend(d)
|
||||
|
||||
for module_name, filepath, _type in all_plugins:
|
||||
try:
|
||||
self.cached_import(module_name, filepath, _type)
|
||||
except Exception as e:
|
||||
logger.exception(
|
||||
f'❌ 插件{filepath.stem}导入失败, 错误代码: {e}'
|
||||
)
|
||||
continue
|
||||
|
||||
'''
|
||||
max_workers = min(12, (os.cpu_count() or 1) * 2)
|
||||
with ThreadPoolExecutor(max_workers=max_workers) as executor:
|
||||
_ = {
|
||||
@ -222,6 +230,7 @@ class GsServer:
|
||||
): module_name
|
||||
for module_name, filepath, _type in all_plugins
|
||||
}
|
||||
'''
|
||||
|
||||
core_config.lazy_write_config()
|
||||
logger.success('[GsCore] 插件加载完成!')
|
||||
|
@ -58,14 +58,12 @@ async def lifespan(app: FastAPI):
|
||||
'[GsCore] 执行启动Hook函数中!',
|
||||
[_def.__name__ for _def in core_start_def],
|
||||
)
|
||||
ctask = []
|
||||
for _def in core_start_def:
|
||||
if asyncio.iscoroutinefunction(_def):
|
||||
asyncio.create_task(_def())
|
||||
else:
|
||||
ctask.append(asyncio.to_thread(_def))
|
||||
if ctask:
|
||||
await asyncio.gather(*ctask)
|
||||
asyncio.create_task(asyncio.to_thread(_def))
|
||||
|
||||
except Exception as e:
|
||||
logger.exception(e)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user