ErisPulse 1.1.3__py3-none-any.whl → 1.1.6__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- ErisPulse/__init__.py +7 -9
- ErisPulse/adapter.py +21 -4
- {erispulse-1.1.3.dist-info → erispulse-1.1.6.dist-info}/METADATA +1 -1
- {erispulse-1.1.3.dist-info → erispulse-1.1.6.dist-info}/RECORD +7 -7
- {erispulse-1.1.3.dist-info → erispulse-1.1.6.dist-info}/WHEEL +0 -0
- {erispulse-1.1.3.dist-info → erispulse-1.1.6.dist-info}/entry_points.txt +0 -0
- {erispulse-1.1.3.dist-info → erispulse-1.1.6.dist-info}/top_level.txt +0 -0
ErisPulse/__init__.py
CHANGED
|
@@ -136,15 +136,13 @@ def init():
|
|
|
136
136
|
moduleObj = module_objs[module_name]
|
|
137
137
|
meta_name = moduleObj.moduleInfo["meta"]["name"]
|
|
138
138
|
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
except Exception as e:
|
|
147
|
-
logger.error(f"模块 {meta_name} 注册适配器失败: {e}")
|
|
139
|
+
try:
|
|
140
|
+
if hasattr(moduleObj, "adapterInfo") and isinstance(moduleObj.adapterInfo, dict):
|
|
141
|
+
for platform_name, adapter_class in moduleObj.adapterInfo.items():
|
|
142
|
+
sdk.adapter.register(platform_name, adapter_class)
|
|
143
|
+
logger.info(f"模块 {meta_name} 注册了适配器: {platform_name}")
|
|
144
|
+
except Exception as e:
|
|
145
|
+
logger.error(f"模块 {meta_name} 注册适配器失败: {e}")
|
|
148
146
|
|
|
149
147
|
# ==== 存储模块信息到数据库 ====
|
|
150
148
|
all_modules_info = {}
|
ErisPulse/adapter.py
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import functools
|
|
2
2
|
import asyncio
|
|
3
|
-
from typing import Callable, Any, Dict, List, Type, Optional
|
|
3
|
+
from typing import Callable, Any, Dict, List, Type, Optional, Set
|
|
4
4
|
from collections import defaultdict
|
|
5
5
|
|
|
6
6
|
|
|
@@ -82,22 +82,36 @@ class BaseAdapter:
|
|
|
82
82
|
class AdapterManager:
|
|
83
83
|
def __init__(self):
|
|
84
84
|
self._adapters: Dict[str, BaseAdapter] = {}
|
|
85
|
-
|
|
85
|
+
self._adapter_instances: Dict[Type[BaseAdapter], BaseAdapter] = {}
|
|
86
|
+
self._started_instances: Set[BaseAdapter] = set()
|
|
86
87
|
def register(self, platform: str, adapter_class: Type[BaseAdapter]) -> bool:
|
|
87
88
|
if not issubclass(adapter_class, BaseAdapter):
|
|
88
89
|
raise TypeError("适配器必须继承自BaseAdapter")
|
|
89
90
|
from . import sdk
|
|
90
|
-
|
|
91
|
+
|
|
92
|
+
if adapter_class in self._adapter_instances:
|
|
93
|
+
self._adapters[platform] = self._adapter_instances[adapter_class]
|
|
94
|
+
else:
|
|
95
|
+
instance = adapter_class(sdk)
|
|
96
|
+
self._adapters[platform] = instance
|
|
97
|
+
self._adapter_instances[adapter_class] = instance
|
|
98
|
+
|
|
91
99
|
return True
|
|
92
100
|
|
|
93
101
|
async def startup(self, platforms: List[str] = None):
|
|
94
102
|
if platforms is None:
|
|
95
|
-
platforms = self._adapters.keys()
|
|
103
|
+
platforms = list(self._adapters.keys())
|
|
96
104
|
|
|
97
105
|
for platform in platforms:
|
|
98
106
|
if platform not in self._adapters:
|
|
99
107
|
raise ValueError(f"平台 {platform} 未注册")
|
|
100
108
|
adapter = self._adapters[platform]
|
|
109
|
+
|
|
110
|
+
# 如果该实例已经被启动过,跳过
|
|
111
|
+
if adapter in self._started_instances:
|
|
112
|
+
continue
|
|
113
|
+
|
|
114
|
+
self._started_instances.add(adapter)
|
|
101
115
|
asyncio.create_task(self._run_adapter(adapter, platform))
|
|
102
116
|
|
|
103
117
|
async def _run_adapter(self, adapter: BaseAdapter, platform: str):
|
|
@@ -107,6 +121,9 @@ class AdapterManager:
|
|
|
107
121
|
while retry_count < max_retry:
|
|
108
122
|
try:
|
|
109
123
|
await adapter.start()
|
|
124
|
+
sdk.logger.debug(f"尝试启动适配器 {platform},实例ID: {id(adapter)}")
|
|
125
|
+
if adapter in self._started_instances:
|
|
126
|
+
sdk.logger.info(f"适配器 {platform}(实例ID: {id(adapter)})已启动,跳过")
|
|
110
127
|
break
|
|
111
128
|
except Exception as e:
|
|
112
129
|
retry_count += 1
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: ErisPulse
|
|
3
|
-
Version: 1.1.
|
|
3
|
+
Version: 1.1.6
|
|
4
4
|
Summary: ErisPulse 是一个模块化、可扩展的异步 Python SDK 框架,主要用于构建高效、可维护的机器人应用程序。
|
|
5
5
|
Author-email: "艾莉丝·格雷拉特(WSu2059)" <wsu2059@qq.com>, runoneall <runoobsteve@gmail.com>
|
|
6
6
|
Classifier: Development Status :: 5 - Production/Stable
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
ErisPulse/__init__.py,sha256=
|
|
1
|
+
ErisPulse/__init__.py,sha256=ZQlAumhGUM3skHfBRwSbbP_koy3FJaHiotVh-fD7YYc,7678
|
|
2
2
|
ErisPulse/__main__.py,sha256=-UdhsYP_X7EagomCjo73Y_qQdXwtMbDS5KoOSrI-OcU,32181
|
|
3
|
-
ErisPulse/adapter.py,sha256=
|
|
3
|
+
ErisPulse/adapter.py,sha256=cpynhF4HSSTUdPKlkXnGFf4RCfjzBmXxdXDm3K0M9Hw,5848
|
|
4
4
|
ErisPulse/db.py,sha256=cd2AUfm-ZPzXlU8PLKK23QGd6VF0eSgYQl9dyRRpl_Y,4425
|
|
5
5
|
ErisPulse/logger.py,sha256=HIQMYD75K-PL4IETMlm7V6Eyg0ussZ11_riEw5E5a08,5899
|
|
6
6
|
ErisPulse/mods.py,sha256=M9XQWUQYNZ11m845hxbewBAauWXnysy-aOdLwb5xy_M,3312
|
|
7
7
|
ErisPulse/raiserr.py,sha256=z8BigWkVrBE9dD_dJa5np2YYREwdugyWXKE4_-LEO_Q,2616
|
|
8
8
|
ErisPulse/util.py,sha256=b9TqyRZKkpclN2fkHmWqBl3lnBMnUbucMvKvbqD5Ws8,2541
|
|
9
|
-
erispulse-1.1.
|
|
10
|
-
erispulse-1.1.
|
|
11
|
-
erispulse-1.1.
|
|
12
|
-
erispulse-1.1.
|
|
13
|
-
erispulse-1.1.
|
|
9
|
+
erispulse-1.1.6.dist-info/METADATA,sha256=KQ1UD2ORHTkr4dr1LcshMQ2DZVrrpe96f-AzjxDucTI,2282
|
|
10
|
+
erispulse-1.1.6.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
11
|
+
erispulse-1.1.6.dist-info/entry_points.txt,sha256=AjKvOdYR7QGXVpEJhjUYUwV2JluE4lm9vNbknC3hjOM,155
|
|
12
|
+
erispulse-1.1.6.dist-info/top_level.txt,sha256=Lm_qtkVvNJR8_dXh_qEDdl_12cZGpic-i4HUlVVUMZc,10
|
|
13
|
+
erispulse-1.1.6.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|