Archived
feat(core): requests 兼容异步垫片 + 同步/异步桥
- core/aiohttp_compat.py:以 requests 同形 API(post/get + Response.json/text/ status_code/raise_for_status + HTTPError/RequestException/Timeout)实现异步请求, 使既有 requests 风格代码可「加 await + async def」最小改动迁移;4xx/5xx 不抛、 仅 raise_for_status() 抛(与 requests 语义一致,保住风控判断逻辑) - core/async_bridge.py:run_sync(coro) 经常驻后台事件循环线程执行协程并阻塞等待, 供迁移期同步调用方(遗留 Flask 路由/线程池)复用异步实现 验证:pytest 16/16;ruff All checks passed;pyright 0 errors。
This commit is contained in:
1 parent
9f56f68b66
commit
4962542e78
4 files changed
+301
No files matched your search
@@ -34,6 +34,7 @@ ignore = [
|
||||
# ASYNC109:timeout 参数是有意 API——直接转发给 aiohttp 的 ClientTimeout,
|
||||
# 不是「用 sleep 当超时」的反模式。
|
||||
"core/http_client.py" = ["ASYNC109"]
|
||||
"core/aiohttp_compat.py" = ["ASYNC109"]
|
||||
|
||||
[tool.ruff.lint.isort]
|
||||
known-first-party = ["core", "web", "music_api", "auth_system"]
|
||||
|
||||
Reference in new issue
Block a user