From e43bd390f0344f835dbdb53bec8c2c116cb026a8 Mon Sep 17 00:00:00 2001 From: kyx236 Date: Wed, 28 Jan 2026 06:59:22 +0800 Subject: [PATCH] 3 --- telegram_bot.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/telegram_bot.py b/telegram_bot.py index 2e84739..fb956c5 100644 --- a/telegram_bot.py +++ b/telegram_bot.py @@ -2416,8 +2416,15 @@ class ProvisionerBot: skipped.append(key) continue - # 测试 Key 是否有效 - success, msg = gptmail_service.test_api_key(key) + # 测试 Key 是否有效 (使用线程池避免阻塞,带超时) + try: + success, msg = await asyncio.wait_for( + asyncio.to_thread(gptmail_service.test_api_key, key), + timeout=15 + ) + except asyncio.TimeoutError: + invalid.append(key) + continue if not success: invalid.append(key)