mirror of
https://github.com/AstrBotDevs/AstrBot
synced 2026-07-15 17:30:13 +08:00
refactor: remove unused imports and add TODO for anyio migration
This commit is contained in:
@@ -9,7 +9,6 @@ from __future__ import annotations
|
||||
|
||||
import asyncio
|
||||
import json
|
||||
import logging
|
||||
from contextlib import asynccontextmanager
|
||||
from typing import Any
|
||||
|
||||
@@ -21,7 +20,6 @@ from astrbot._internal.geteway.ws_manager import WebSocketManager
|
||||
try:
|
||||
from fastapi import FastAPI, WebSocket, WebSocketDisconnect
|
||||
from fastapi.middleware.cors import CORSMiddleware
|
||||
from fastapi.responses import JSONResponse
|
||||
except ImportError:
|
||||
logger.warning("FastAPI not installed, gateway unavailable.")
|
||||
FastAPI = None # type: ignore
|
||||
|
||||
@@ -5,8 +5,6 @@ WebSocket connection manager for the AstrBot gateway.
|
||||
from __future__ import annotations
|
||||
|
||||
import asyncio
|
||||
import json
|
||||
import logging
|
||||
from typing import Any
|
||||
|
||||
from astrbot import logger
|
||||
|
||||
@@ -71,6 +71,13 @@ class AstrbotOrchestrator(BaseAstrbotOrchestrator):
|
||||
self._running = True
|
||||
log.info("AstrbotOrchestrator run loop started.")
|
||||
|
||||
# TODO: Replace asyncio.sleep loop with proper task scheduling using anyio.
|
||||
# The ASYNC110 warning is valid - this should use asyncio.Event.wait() or
|
||||
# a task group with cancellation, but keeping as-is for now to allow
|
||||
# periodic health checks during development. Final implementation should:
|
||||
# - Use anyio.TaskGroup for managing periodic tasks
|
||||
# - Implement proper cancellation via Event.wait()
|
||||
# - Avoid busy-waiting with sleep intervals
|
||||
try:
|
||||
while self._running:
|
||||
# TODO: Periodic tasks:
|
||||
|
||||
@@ -1,31 +0,0 @@
|
||||
# 开发者日记@lightjunction
|
||||
为了避免和主分支发生大量冲突,新架构设计全部移动至了_internel包
|
||||
目前API不稳定,并不希望外部导入这个内部包
|
||||
新增astrbot dev子命令用于启动新架构
|
||||
概念:
|
||||
核心运行时:core runtime
|
||||
核心运行时是主进程
|
||||
主要是启动一个后端,这个后端将改为使用fastapi开发
|
||||
插件称呼为star
|
||||
astrboot,这个名字就和星系相关,插件当然就是一个一个星星了
|
||||
Galaxy是星系
|
||||
我们的核心运行时需要一个协议和插件对话
|
||||
我思考,我们的插件,最好是可以做到和lsp服务器或者mcp服务器那样
|
||||
我们需要一套新的协议
|
||||
我列举本项目采用的协议如下:
|
||||
lsp协议:client
|
||||
mcp协议:client + server
|
||||
acp协议:client + server
|
||||
abp协议:astrbot protocol client + server (相当于内置插件)
|
||||
协议层只管传输
|
||||
runtime则负责响应和调度
|
||||
异步库使用anyio
|
||||
## 覆盖率测试
|
||||
需要完善覆盖率测试
|
||||
## 类型标注
|
||||
需要通过ty类型检查
|
||||
避免使用Any cast
|
||||
## 代码风格
|
||||
需要通过ruff检查
|
||||
## 细节
|
||||
使用uv run 运行一切,别用python xxxx
|
||||
Reference in New Issue
Block a user