mirror of
https://github.com/j93es/browser-use-oauth.git
synced 2026-06-04 08:11:53 +09:00
[ADD] 재시도 큐 시스템 추가 및 관련 함수 구현
This commit is contained in:
parent
686333e75c
commit
18a575a8af
4 changed files with 234 additions and 28 deletions
|
|
@ -3,7 +3,7 @@ import os
|
|||
import csv
|
||||
|
||||
from lib.utils import notify_backend, read_lines_between, is_html_url
|
||||
from lib.browser_use.agents import extract_oauth_list, test_oauth_login
|
||||
from lib.browser_use.agents import extract_oauth_list, test_oauth_login, start_retry_queue_processor, get_retry_queue_status
|
||||
from lib.utils.progress import current_progress, load_progress, save_progress, progress_file
|
||||
|
||||
async def scan_one_url(url: str, skip_html_check: bool = False):
|
||||
|
|
@ -66,11 +66,16 @@ async def main_loop(
|
|||
filepath: str, start_line: int, end_line: int, skip_html_check: bool = False
|
||||
):
|
||||
"""지정된 URL 목록에 대해 스캔을 실행하는 메인 루프"""
|
||||
# 재시도 큐 처리기 시작
|
||||
await start_retry_queue_processor()
|
||||
|
||||
target_list = read_lines_between(
|
||||
filepath=filepath, start_line=start_line, end_line=end_line
|
||||
)
|
||||
|
||||
current_progress["total"] = len(target_list)
|
||||
# 전체 목록 길이를 저장 (재개 시에도 유지되어야 함)
|
||||
total_count = len(target_list)
|
||||
current_progress["total"] = total_count
|
||||
current_progress["start_line"] = start_line
|
||||
current_progress["current_index"] = 0
|
||||
|
||||
|
|
@ -84,15 +89,23 @@ async def main_loop(
|
|||
if resume == 'y':
|
||||
start_index = prev_progress.get("current_index", 0)
|
||||
current_progress["current_index"] = start_index
|
||||
# 전체 개수는 원래 목록 길이로 유지
|
||||
current_progress["total"] = total_count
|
||||
target_list = target_list[start_index:]
|
||||
print(f"✅ {start_index}번째부터 재개합니다.")
|
||||
|
||||
for i, url in enumerate(target_list):
|
||||
actual_index = current_progress["current_index"] + i
|
||||
# current_index는 전체 목록에서의 현재 위치를 나타냄
|
||||
current_url_index = current_progress["current_index"]
|
||||
current_progress["current_url"] = url
|
||||
|
||||
print(f"\n🔄 Processing {actual_index + 1}/{current_progress['total']}: {url}")
|
||||
print(f"📍 {os.path.basename(filepath)}의 {start_line + actual_index}번째 줄")
|
||||
print(f"\n🔄 Processing {current_url_index + 1}/{current_progress['total']}: {url}")
|
||||
print(f"📍 {os.path.basename(filepath)}의 {start_line + current_url_index}번째 줄")
|
||||
|
||||
# 재시도 큐 상태 확인 및 출력
|
||||
retry_status = await get_retry_queue_status()
|
||||
if retry_status["queue_length"] > 0:
|
||||
print(f"⏳ 재시도 큐에 {retry_status['queue_length']}개 작업 대기 중")
|
||||
|
||||
if i > 0:
|
||||
print("⏳ API 쿼터 보호를 위해 30초 대기 중...")
|
||||
|
|
@ -100,7 +113,23 @@ async def main_loop(
|
|||
|
||||
await scan_one_url(url, skip_html_check=skip_html_check)
|
||||
|
||||
current_progress["current_index"] = actual_index + 1
|
||||
# 스캔 완료 후 재시도 큐 상태 확인
|
||||
retry_status_after = await get_retry_queue_status()
|
||||
if retry_status_after["queue_length"] > 0:
|
||||
print(f"📊 스캔 완료 후 재시도 큐 상태: {retry_status_after['queue_length']}개 작업 대기 중")
|
||||
|
||||
# 다음 URL로 진행
|
||||
current_progress["current_index"] = current_url_index + 1
|
||||
save_progress()
|
||||
|
||||
print(f"\n🎉 모든 스캔이 완료되었습니다! ({current_progress['total']}개 URL)")
|
||||
# 모든 URL 처리 완료 후 재시도 큐가 빌 때까지 대기
|
||||
print("\n🔄 모든 URL 처리 완료. 재시도 큐 처리 대기 중...")
|
||||
while True:
|
||||
retry_status = await get_retry_queue_status()
|
||||
if retry_status["queue_length"] == 0:
|
||||
break
|
||||
print(f"⏳ 재시도 큐에 {retry_status['queue_length']}개 작업 남음. 30초 후 다시 확인...")
|
||||
await asyncio.sleep(30)
|
||||
|
||||
print(f"\n🎉 모든 스캔이 완료되었습니다! ({total_count}개 URL)")
|
||||
print("🎉 재시도 큐도 모두 처리되었습니다!")
|
||||
Loading…
Add table
Add a link
Reference in a new issue