refactor(timeouts): make BROWSER_SUBMIT_NAV_TIMEOUT a per-platform defaultdict

This commit is contained in:
Barrett Ruth 2026-03-05 11:47:10 -05:00
parent 789cb3205b
commit 0082ecc9f4
3 changed files with 7 additions and 3 deletions

View file

@ -33,6 +33,7 @@ from .timeouts import (
BROWSER_NAV_TIMEOUT, BROWSER_NAV_TIMEOUT,
BROWSER_SESSION_TIMEOUT, BROWSER_SESSION_TIMEOUT,
BROWSER_SETTLE_DELAY, BROWSER_SETTLE_DELAY,
BROWSER_SUBMIT_NAV_TIMEOUT,
BROWSER_TURNSTILE_POLL, BROWSER_TURNSTILE_POLL,
HTTP_TIMEOUT, HTTP_TIMEOUT,
) )
@ -361,7 +362,7 @@ def _submit_headless(
page.wait_for_timeout(BROWSER_SETTLE_DELAY) page.wait_for_timeout(BROWSER_SETTLE_DELAY)
page.locator('button[type="submit"]').click() page.locator('button[type="submit"]').click()
page.wait_for_url( page.wait_for_url(
lambda url: "/submissions/me" in url, timeout=BROWSER_NAV_TIMEOUT lambda url: "/submissions/me" in url, timeout=BROWSER_SUBMIT_NAV_TIMEOUT["atcoder"]
) )
except Exception as e: except Exception as e:
submit_error = str(e) submit_error = str(e)

View file

@ -397,7 +397,7 @@ def _submit_headless(
try: try:
page.wait_for_url( page.wait_for_url(
lambda url: "/my" in url or "/status" in url, lambda url: "/my" in url or "/status" in url,
timeout=BROWSER_SUBMIT_NAV_TIMEOUT, timeout=BROWSER_SUBMIT_NAV_TIMEOUT["codeforces"],
) )
except Exception: except Exception:
err_el = page.query_selector("span.error") err_el = page.query_selector("span.error")

View file

@ -1,8 +1,11 @@
from collections import defaultdict
HTTP_TIMEOUT = 15.0 HTTP_TIMEOUT = 15.0
BROWSER_SESSION_TIMEOUT = 15000 BROWSER_SESSION_TIMEOUT = 15000
BROWSER_NAV_TIMEOUT = 10000 BROWSER_NAV_TIMEOUT = 10000
BROWSER_SUBMIT_NAV_TIMEOUT = BROWSER_NAV_TIMEOUT * 2 BROWSER_SUBMIT_NAV_TIMEOUT: defaultdict[str, int] = defaultdict(lambda: BROWSER_NAV_TIMEOUT)
BROWSER_SUBMIT_NAV_TIMEOUT["codeforces"] = BROWSER_NAV_TIMEOUT * 2
BROWSER_TURNSTILE_POLL = 5000 BROWSER_TURNSTILE_POLL = 5000
BROWSER_ELEMENT_WAIT = 10000 BROWSER_ELEMENT_WAIT = 10000
BROWSER_SETTLE_DELAY = 500 BROWSER_SETTLE_DELAY = 500