From ad84ee62c4c73400905bbcc3b12104f3bec75cce Mon Sep 17 00:00:00 2001 From: crypto_predictor Date: Sat, 7 Mar 2026 12:22:53 +0800 Subject: [PATCH] chore: remove session reuse and pin proxy to 7898 for lark notifier --- utils/send_msg.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/utils/send_msg.py b/utils/send_msg.py index 5cdeeb7..2e39f1f 100644 --- a/utils/send_msg.py +++ b/utils/send_msg.py @@ -8,9 +8,12 @@ class LarkNotifier: self.url = "https://zhiyinzhe.xyz/sendMsg/api/send" self.bot_name = bot_name self.receive_id = receive_id - - # 使用 Session 可以复用底层 TCP 连接,提升发送效率 - self.session = requests.Session() + + # 代理固定为本地 7898 端口 + self.proxies = { + "http": "socks5h://127.0.0.1:7898", + "https": "socks5h://127.0.0.1:7898" + } def send_alert(self, title: str, content: str): """ @@ -26,8 +29,8 @@ class LarkNotifier: } try: - # 使用 data=payload 发送 Form Data - response = self.session.post(self.url, data=payload, timeout=5) + # 每次请求直接调用 requests.post,不复用 Session + response = requests.post(self.url, data=payload, timeout=5, proxies=self.proxies) response.raise_for_status() print(f"告警发送成功: {title}") except Exception as e: