From baa055a36e039d2020912abc22f7c9a811d4c604 Mon Sep 17 00:00:00 2001 From: Guillem Hernandez Sola Date: Sat, 18 Apr 2026 11:18:55 +0200 Subject: [PATCH] Added some rss fixes --- rss2bsky.py | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/rss2bsky.py b/rss2bsky.py index e3b5a0f..c6e0b68 100644 --- a/rss2bsky.py +++ b/rss2bsky.py @@ -57,8 +57,8 @@ class RetryConfig: post_retry_delay_seconds: int = 2 # Login hardening - login_max_attempts: int = 4 - login_base_delay_seconds: int = 10 + login_max_attempts: int = 5 + login_base_delay_seconds: int = 2 login_max_delay_seconds: int = 600 login_jitter_seconds: float = 1.5 @@ -1088,20 +1088,34 @@ def login_with_backoff( except Exception as e: logging.exception("❌ Login exception") + # Rate-limited login: retry first, cooldown only if exhausted if is_rate_limited_error(e): + if attempt < max_attempts: + wait_seconds = get_rate_limit_wait_seconds(e, base_delay, cfg) + wait_seconds = min(wait_seconds, max_delay) + random.uniform(0, jitter_max) + logging.warning( + f"⏳ Login rate-limited. Retrying in {wait_seconds:.1f}s " + f"(attempt {attempt}/{max_attempts})" + ) + time.sleep(wait_seconds) + continue + activate_post_creation_cooldown_from_error(e, cooldown_path, cfg) return False + # Bad credentials: fail fast if is_auth_error(e): logging.error("❌ Authentication failed (bad handle/password/app-password).") return False + # Network/transient: bounded retry if attempt < max_attempts and (is_network_error(e) or is_timeout_error(e)): delay = min(base_delay * attempt, max_delay) + random.uniform(0, jitter_max) logging.warning(f"⏳ Transient login failure. Retrying in {delay:.1f}s...") time.sleep(delay) continue + # Other errors: bounded retry if attempt < max_attempts: delay = min(base_delay * attempt, max_delay) + random.uniform(0, jitter_max) logging.warning(f"⏳ Login retry in {delay:.1f}s...")