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)