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