mirror of
https://github.com/fawney19/Aether.git
synced 2026-09-02 01:10:23 +08:00
fix(proxy-resolver): 将 resolve_ops_proxy_config 改为异步调用避免阻塞事件循环
在 anyrouter/nekocode/sub2api/yescode 架构及 service.py 中, 将同步的 resolve_ops_proxy_config 替换为 resolve_ops_proxy_config_async, 通过 asyncio.to_thread 包装避免同步 DB 查询阻塞事件循环。
This commit is contained in:
@@ -10,6 +10,7 @@ from src.services.proxy_node.resolver import (
|
||||
build_post_kwargs_async,
|
||||
build_stream_kwargs,
|
||||
build_stream_kwargs_async,
|
||||
resolve_ops_proxy_config_async,
|
||||
resolve_proxy_info_async,
|
||||
)
|
||||
|
||||
@@ -97,3 +98,19 @@ class TestProxyResolverCompression:
|
||||
"url": "socks5://proxy.example.com:1080",
|
||||
"source": "provider",
|
||||
}
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_resolve_ops_proxy_config_async_preserves_legacy_proxy(
|
||||
self,
|
||||
monkeypatch: pytest.MonkeyPatch,
|
||||
) -> None:
|
||||
monkeypatch.setattr(
|
||||
"src.services.proxy_node.resolver.get_system_proxy_config",
|
||||
lambda: None,
|
||||
)
|
||||
proxy, tunnel_node_id = await resolve_ops_proxy_config_async(
|
||||
{"proxy": "http://proxy.example.com:8080"}
|
||||
)
|
||||
|
||||
assert proxy == "http://proxy.example.com:8080"
|
||||
assert tunnel_node_id is None
|
||||
|
||||
Reference in New Issue
Block a user