mirror of
https://github.com/zhenxun-org/zhenxun_bot.git
synced 2025-12-14 21:52:56 +08:00
fix(zhenxun): 修复 HTTP 客户端初始化逻辑错误 (#2014)
Some checks failed
检查bot是否运行正常 / bot check (push) Has been cancelled
CodeQL Code Security Analysis / Analyze (${{ matrix.language }}) (none, javascript-typescript) (push) Has been cancelled
CodeQL Code Security Analysis / Analyze (${{ matrix.language }}) (none, python) (push) Has been cancelled
Sequential Lint and Type Check / ruff-call (push) Has been cancelled
Release Drafter / Update Release Draft (push) Has been cancelled
Force Sync to Aliyun / sync (push) Has been cancelled
Update Version / update-version (push) Has been cancelled
Sequential Lint and Type Check / pyright-call (push) Has been cancelled
Some checks failed
检查bot是否运行正常 / bot check (push) Has been cancelled
CodeQL Code Security Analysis / Analyze (${{ matrix.language }}) (none, javascript-typescript) (push) Has been cancelled
CodeQL Code Security Analysis / Analyze (${{ matrix.language }}) (none, python) (push) Has been cancelled
Sequential Lint and Type Check / ruff-call (push) Has been cancelled
Release Drafter / Update Release Draft (push) Has been cancelled
Force Sync to Aliyun / sync (push) Has been cancelled
Update Version / update-version (push) Has been cancelled
Sequential Lint and Type Check / pyright-call (push) Has been cancelled
- 将 httpx.AsyncClient 实例化逻辑封装到 get_async_client 函数中 - 统一全局客户端和测试环境客户端的创建方式 - 提高代码复用性和可维护性
This commit is contained in:
parent
2fed781350
commit
977f0b13b3
@ -61,7 +61,7 @@ async def _():
|
|||||||
"将默认使用新版 'proxy' 参数语法。"
|
"将默认使用新版 'proxy' 参数语法。"
|
||||||
)
|
)
|
||||||
|
|
||||||
_client = httpx.AsyncClient(
|
_client = get_async_client(
|
||||||
headers=get_user_agent(),
|
headers=get_user_agent(),
|
||||||
follow_redirects=True,
|
follow_redirects=True,
|
||||||
**client_kwargs,
|
**client_kwargs,
|
||||||
@ -90,7 +90,7 @@ def get_client() -> AsyncClient:
|
|||||||
raise RuntimeError("全局 httpx.AsyncClient 未初始化,请检查启动流程。")
|
raise RuntimeError("全局 httpx.AsyncClient 未初始化,请检查启动流程。")
|
||||||
# 在测试环境中创建临时客户端
|
# 在测试环境中创建临时客户端
|
||||||
logger.warning("在测试环境中创建临时HTTP客户端", "HTTPClient")
|
logger.warning("在测试环境中创建临时HTTP客户端", "HTTPClient")
|
||||||
_client = httpx.AsyncClient(
|
_client = get_async_client(
|
||||||
headers=get_user_agent(),
|
headers=get_user_agent(),
|
||||||
follow_redirects=True,
|
follow_redirects=True,
|
||||||
)
|
)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user