(self)
| 23 | return cls._instance |
| 24 | |
| 25 | def __init__(self): |
| 26 | if self._initialized: |
| 27 | return |
| 28 | |
| 29 | self._tasks: Set[asyncio.Task] = set() |
| 30 | self._resources: Set[Any] = set() # 需要关闭的资源 |
| 31 | self._shutdown_event = asyncio.Event() |
| 32 | self._initialized = True |
| 33 | log.debug("TaskManager initialized") |
| 34 | |
| 35 | def register_task(self, task: asyncio.Task, description: str = None) -> asyncio.Task: |
| 36 | """注册一个任务供生命周期管理""" |