Archived
refactor: geo 走原生异步 HTTP,清掉短链展开死链
「同步转异步」的残留清理: 1) auth_system/geo.query_ip_province 原经 core.sync_http 同步门面(在后台 事件循环桥接)查询归属地,但其唯一调用方 record_login_location 的入口 本来就是 async 的登录链路(web/routers/auth 里还套了一层 to_thread)。 改为直接 await core.http_client——桥接纯属多余,顺带把 record_login_location 转 async,落库仍走同步 sqlite 但经 asyncio.to_thread 卸载,避免 sqlite busy 等待(最长 15s)冻结事件循环。 调用方两处(普通用户/管理员登录)去掉 to_thread 包装,直接 await。 2) MusicAPIService._extract_music_id 是死代码:ID 归一化早已迁到 web.request_utils(注释里明说是它的迁移口径),全仓零调用。它也是 core.utils.expand_shortlink 的唯一调用方——一并删除,core.utils 由此 彻底不再 import core.sync_http。 门禁:ruff 全过 / pyright 0-0 / pytest 387 项全绿(0 失败)。
This commit is contained in:
1 parent
064a89d726
commit
b089dadac2
5 files changed
+29
-81
No files matched your search
@@ -133,7 +133,7 @@ def test_admin_without_email_blocked_fail_closed(env):
|
||||
|
||||
def test_geo_ban_bumps_seq_again(env, monkeypatch):
|
||||
"""异地多省封禁:login_seq 再递增一次(已签发中的会话全部顶下线)。"""
|
||||
def _banned(user, ip):
|
||||
async def _banned(user, ip):
|
||||
return True, {'province': 'X'}
|
||||
|
||||
monkeypatch.setattr(auth, 'record_login_location', _banned)
|
||||
|
||||
Reference in new issue
Block a user