sdsad
This commit is contained in:
@@ -268,14 +268,18 @@ class AutoCursorService:
|
||||
imported = await self.import_email_accounts(accounts)
|
||||
total_imported += imported
|
||||
|
||||
# 导入后等待一秒,确保数据库状态完全更新
|
||||
logger.debug("等待数据库状态更新...")
|
||||
await asyncio.sleep(2)
|
||||
|
||||
# 每次获取到新邮箱并成功导入后,立即确保注册进程在运行
|
||||
if imported > 0 and self.reg_enabled:
|
||||
new_count = pending_count + imported
|
||||
if new_count >= self.min_email_to_process:
|
||||
logger.info(f"已获取到 {imported} 个新邮箱,总可用邮箱数 {new_count},确保注册进程运行")
|
||||
# 重新查询一次确保数据是最新的
|
||||
pending_count = await self.count_pending_accounts()
|
||||
if pending_count >= self.min_email_to_process:
|
||||
logger.info(f"已获取到 {imported} 个新邮箱,总可用邮箱数 {pending_count},确保注册进程运行")
|
||||
if not self.registration_process or self.registration_process.poll() is not None:
|
||||
await self.start_registration_process()
|
||||
pending_count = new_count # 更新计数器
|
||||
|
||||
if imported < 15: # 每次API应返回15个账号
|
||||
logger.warning(f"获取到的邮箱少于预期 ({imported} < 15),可能没有更多邮箱可用")
|
||||
@@ -294,7 +298,10 @@ class AutoCursorService:
|
||||
logger.info("注册进程已在运行中")
|
||||
return
|
||||
|
||||
# 检查可用邮箱数量
|
||||
# 启动前等待1秒,确保数据库状态已更新
|
||||
await asyncio.sleep(1)
|
||||
|
||||
# 再次检查可用邮箱数量,确保使用最新状态
|
||||
pending_count = await self.count_pending_accounts()
|
||||
if pending_count < self.min_email_to_process:
|
||||
logger.warning(f"可用邮箱数量不足 ({pending_count} < {self.min_email_to_process}),暂不启动注册进程")
|
||||
@@ -403,6 +410,9 @@ class AutoCursorService:
|
||||
self.reg_enabled = current_status
|
||||
logger.info(f"注册状态变化为: {'开启' if self.reg_enabled else '关闭'}")
|
||||
|
||||
# 状态变化后等待2秒,确保数据库状态稳定
|
||||
await asyncio.sleep(2)
|
||||
|
||||
if self.reg_enabled:
|
||||
# 开启注册时,先检查并获取邮箱
|
||||
await self.check_and_fetch_emails()
|
||||
@@ -415,6 +425,9 @@ class AutoCursorService:
|
||||
# 关闭注册时,停止注册进程
|
||||
self.stop_registration_process()
|
||||
|
||||
# 等待一会,确保上一步操作完全完成
|
||||
await asyncio.sleep(1)
|
||||
|
||||
# 2. 如果注册已开启,检查并获取邮箱
|
||||
if self.reg_enabled:
|
||||
await self.check_and_fetch_emails()
|
||||
@@ -430,8 +443,11 @@ class AutoCursorService:
|
||||
if current_time - last_upload_time >= self.upload_interval:
|
||||
await self.upload_accounts()
|
||||
last_upload_time = current_time
|
||||
# 上传后等待,确保数据库状态更新
|
||||
await asyncio.sleep(2)
|
||||
|
||||
# 4. 等待下一次检查
|
||||
logger.debug(f"等待 {self.check_interval} 秒后进行下一次检查")
|
||||
for _ in range(self.check_interval):
|
||||
if not self.running:
|
||||
break
|
||||
|
||||
Reference in New Issue
Block a user