mirror of
https://github.com/AstrBotDevs/AstrBot
synced 2026-07-15 17:30:13 +08:00
fix: make registered_web_apis/_register_tasks instance vars, add reset_runtime_registrations
Class-level list vars caused cross-instance sharing. Tests expecting isolated registration containers failed. Move to __init__ and add the reset_runtime_registrations helper that tests depend on.
This commit is contained in:
@@ -101,6 +101,9 @@ class Context:
|
||||
self.cron_manager = cron_manager
|
||||
"""Cron job manager, initialized by core lifecycle."""
|
||||
self.subagent_orchestrator = subagent_orchestrator
|
||||
self.registered_web_apis: list = []
|
||||
self._register_tasks: list[Awaitable] = []
|
||||
self._star_manager = None
|
||||
|
||||
async def llm_generate(
|
||||
self,
|
||||
@@ -704,6 +707,11 @@ class Context:
|
||||
)
|
||||
star_handlers_registry.append(md)
|
||||
|
||||
def reset_runtime_registrations(self) -> None:
|
||||
"""Reset runtime registration containers (web APIs and tasks)."""
|
||||
self.registered_web_apis.clear()
|
||||
self._register_tasks.clear()
|
||||
|
||||
def register_task(self, task: Awaitable, desc: str) -> None:
|
||||
"""[DEPRECATED]注册一个异步任务。
|
||||
|
||||
|
||||
Reference in New Issue
Block a user