fix(douyu): 修复斗鱼链路 P0/P1 隐患并增强 P2 运维队列可观测性

This commit is contained in:
yml
2026-11-29 14:10:24 +08:00
parent be7146a9ef
commit d12d9e02b3
51 changed files with 2510 additions and 561 deletions
+15 -1
View File
@@ -7,7 +7,7 @@ import re
import secrets
import time
from collections.abc import Callable
from typing import Any, cast
from typing import Any, Self, cast
from urllib.parse import parse_qs, unquote, urlsplit, urlunsplit
import requests
@@ -2319,3 +2319,17 @@ class DouyuActivityClient:
"new_balance": self._xpd_int(info.get("newBalance")),
"raw": info,
}
def close(self) -> None:
"""关闭底层 HTTP 会话,释放连接池。"""
session = getattr(self, "session", None)
if session is not None:
close = getattr(session, "close", None)
if callable(close):
close()
def __enter__(self) -> Self:
return self
def __exit__(self, *_exc: object) -> None:
self.close()