mirror of
https://github.com/j93es/browser-use-oauth.git
synced 2026-06-04 05:31:51 +09:00
[Update] 레이트 리밋 등의 에러 발생 시 1분 간 멈추고 실행
This commit is contained in:
parent
1b0a0deeb4
commit
61b6b8b356
1 changed files with 93 additions and 74 deletions
23
main.py
23
main.py
|
|
@ -133,6 +133,7 @@ async def scan_one_url(url: str, skip_html_check: bool = False):
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"⚠️ Failed to notify backend: {e}")
|
print(f"⚠️ Failed to notify backend: {e}")
|
||||||
|
|
||||||
|
while True:
|
||||||
# 2) Browser + Context 생성
|
# 2) Browser + Context 생성
|
||||||
browser = Browser(config=BrowserConfig(**browser_config_kwargs()))
|
browser = Browser(config=BrowserConfig(**browser_config_kwargs()))
|
||||||
context = BrowserContext(
|
context = BrowserContext(
|
||||||
|
|
@ -207,12 +208,30 @@ async def scan_one_url(url: str, skip_html_check: bool = False):
|
||||||
await context.close() # 브라우저 컨텍스트 종료 (탭/세션 닫기)
|
await context.close() # 브라우저 컨텍스트 종료 (탭/세션 닫기)
|
||||||
await browser.close() # 실제 브라우저 프로세스 종료
|
await browser.close() # 실제 브라우저 프로세스 종료
|
||||||
|
|
||||||
|
# 성공적으로 처리했으므로 반복문 탈출
|
||||||
|
break
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"❌ Error scanning {url}: {e}")
|
print(f"⚠️ 429 에러 발생, 60초 대기 후 재시도합니다. (URL: {url})")
|
||||||
# 에러 발생 시에도 Agent와 Browser는 닫아야 합니다.
|
|
||||||
|
# 리소스 정리
|
||||||
|
try:
|
||||||
await agent.close()
|
await agent.close()
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
try:
|
||||||
await context.close()
|
await context.close()
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
try:
|
||||||
await browser.close()
|
await browser.close()
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
|
# 1분 대기
|
||||||
|
await asyncio.sleep(60)
|
||||||
|
# 반복문을 통해 재시도
|
||||||
|
continue
|
||||||
|
|
||||||
async def loop(filepath: str, start_line: int, end_line: int, skip_html_check: bool = False):
|
async def loop(filepath: str, start_line: int, end_line: int, skip_html_check: bool = False):
|
||||||
# 인자값으로 받은 파일 경로와 줄 범위를 통해 도메인 리스트 생성
|
# 인자값으로 받은 파일 경로와 줄 범위를 통해 도메인 리스트 생성
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue