From 91c0b6202d6aff5477a843f92dad3fcb2bbbf9c9 Mon Sep 17 00:00:00 2001 From: hkyc Date: Thu, 22 May 2025 22:59:52 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=82=AE=E7=AE=B1API?= =?UTF-8?q?=E4=BD=BF=E7=94=A8=E9=80=BB=E8=BE=91=EF=BC=8C=E9=99=90=E5=88=B6?= =?UTF-8?q?=E6=AF=8F=E6=AC=A1=E6=B3=A8=E5=86=8C=E6=B5=81=E7=A8=8B=E5=8F=AA?= =?UTF-8?q?=E8=8E=B7=E5=8F=96=E4=B8=80=E4=B8=AA=E9=82=AE=E7=AE=B1=E8=B4=A6?= =?UTF-8?q?=E5=8F=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ThreadManagerWithPyno.py | 44 +++++++++++++++++++++------------------- 1 file changed, 23 insertions(+), 21 deletions(-) diff --git a/ThreadManagerWithPyno.py b/ThreadManagerWithPyno.py index 3519a7e..472a83d 100644 --- a/ThreadManagerWithPyno.py +++ b/ThreadManagerWithPyno.py @@ -2,6 +2,7 @@ from concurrent.futures import ThreadPoolExecutor import json import os import threading +import time from ProxyPool import ProxyPool from SteamRegistrationWithPyno import SteamRegistrationWithPyno from EmailAPIClient import EmailAPIClient @@ -81,10 +82,12 @@ class ThreadManagerWithPyno: registration.main(email_data) def get_email_from_api(self): - """从API获取邮箱账号""" + """从API获取邮箱账号 - 每次只获取一个""" try: + print("从API获取单个邮箱账号...") email_data = self.email_api_client.get_email_credentials() if email_data: + print(f"获取到邮箱: {email_data['email']}") return email_data except Exception as e: print(f"从API获取邮箱失败: {e}") @@ -117,13 +120,13 @@ class ThreadManagerWithPyno: self._running = True try: if self.email_source == "api": - # 使用API获取邮箱 - while self._running and (self.reg_count == 0 or self.processed_count < self.reg_count): - email_data = self.get_email_from_api() - if not email_data: - print("无法从API获取邮箱,任务停止") - break - self.executor.submit(self.process_email, email_data) + # 使用API获取邮箱 - 只获取一个 + email_data = self.get_email_from_api() + if not email_data: + print("无法从API获取邮箱,任务停止") + return + # 处理单个邮箱 + self.process_email(email_data) else: # 使用本地文件获取邮箱 with open(self.email_file, "r", encoding="utf-8") as file: @@ -188,19 +191,18 @@ class GUIThreadManagerWithPyno(ThreadManagerWithPyno): try: if self.email_source == "api": - # 使用API获取邮箱 - with ThreadPoolExecutor(max_workers=self.config['executornum']) as self.executor: - while self._running and (self.reg_count == 0 or self.processed_count < self.reg_count): - email_data = self.get_email_from_api() - if not email_data: - self.gui.update_status("API错误", "无法从API获取邮箱", result="失败") - break - - # 跳过已完成的任务 - if email_data['email'] not in self.completed_tasks: - self.executor.submit(self.process_email, email_data) - else: - print(f"跳过已完成的邮箱: {email_data['email']}") + # 使用API获取单个邮箱 + self.gui.update_status("系统消息", "正在从API获取邮箱...") + email_data = self.get_email_from_api() + if not email_data: + self.gui.update_status("API错误", "无法从API获取邮箱", result="失败") + return + + # 处理单个邮箱,不使用线程池 + if email_data['email'] not in self.completed_tasks: + self.process_email(email_data) + else: + self.gui.update_status(email_data['email'], "邮箱已处理过,跳过", result="跳过") else: # 使用本地文件获取邮箱 with open(self.email_file, 'r', encoding='utf-8') as file: