Files
DDSRem 2de976f6b3 Merge pull request #7050 from DDSRem-Dev/codex-comment-migration
docs: 统一全项目中文注释和结构化契约说明
2026-10-17 19:26:29 +08:00

50 lines
1009 B
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
"""
登记命令服务与启动期执行入口。
"""
from concurrent.futures import Future
from typing import Any
from app.application.commands import register_command_class, reset_command_class
from app.command import Command
def configure_command_runtime() -> None:
"""
在命令生命周期启动阶段登记 concrete Command。
"""
register_command_class(Command)
def reset_command_runtime() -> None:
"""
清除 concrete Command 登记,支持重复 lifespan。
"""
reset_command_class()
def init_command() -> None:
"""
初始化命令
"""
configure_command_runtime()
try:
Command()
except Exception:
reset_command_runtime()
raise
def restart_command() -> Future[Any]:
"""
重建命令并返回完成信号。
"""
return Command().init_commands()
def stop_command() -> None:
"""
释放命令 provider;Command 实例本身没有独立关闭资源。
"""
reset_command_runtime()