fix(soccer-scoreboard): fetch a league's schedule window once per miss (2.39.3) - #615
Merged
Merged
Conversation
…s (2.39.3) Every start on ledpi (8 leagues) logged ~90 NameResolutionErrors for site.api.espn.com within a minute, and six hours made 3,812 requests. On a cache miss _fetch_soccer_api_data submitted the window to the core's background service AND fetched the same window on the spot as stand-in data, in both the recent and the upcoming manager; with ESPN rejecting date ranges each window is 29 day requests. A miss now fetches the window once on the calling thread (_fetch_season_directly, which caches it) under a lock per cache key, so the league's other manager waits and reads the cache. Managers share the core's connection pool where the core has one, so connections and DNS lookups are reused across leagues. Live ESPN, 8 leagues, core main: ~440 -> ~260 requests per start, ~470 -> ~250 per hourly refresh; with LEDMatrix #751 39 and ~20. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configuration
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 28 |
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
ChuckBuilds
added a commit
that referenced
this pull request
Oct 4, 2026
…2.39.4) (#618) A per-league mode in switch mode (soccer_esp.1_recent, soccer_usa.1_upcoming, ...) now consults only the named league's manager; when it has nothing to show the mode returns False and the core's empty-mode handling moves on. Merged after #615 (2.39.3 stays as the versions[] and CHANGELOG entry below 2.39.4). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
On ledpi (soccer-scoreboard 2.39.2, 8 leagues, core main), every start or reload logged ~90
NameResolutionErrors forsite.api.espn.comwithin a minute, plusupdate() timed out after 30.0s. Over 6 hours soccer made 3,812 requests: 807 throttled, 410 retries, 198 s of rate-limit wait.Root cause (plugin half)
On a cache miss,
BaseSoccerManager._fetch_soccer_api_data()did two things with the same window:_get_weeks_data()). Since the horizon fix, that "partial" window is the same window.The recent and upcoming managers share the cache key, but they come due in the same
update(), so both missed the cache and both did both. ESPN rejects date ranges, which makes each window 29 day requests (core half: ChuckBuilds/LEDMatrix#751). That is up to 4 x 29 requests per league at every start and every hourly refresh.Each of the 24 managers also had its own
requests.Sessionpool, so connections (and DNS lookups) were never reused across leagues.Fix (soccer-scoreboard 2.39.3)
_fetch_season_directly(which caches it). This costs what the stand-in fetch already cost. The background submission was pure duplication, because the stand-in blocked on the same window anyway.share_connection_pool()with the retry policy they already mount, so all 24 use one pool. The import is guarded withtry/except ImportError(src.common.fetch_serviceisNonein the min-core table), so older cores keep per-manager pools.versions[]entry, CHANGELOG, andupdate_registry.py.ledmatrix_min_versionstays 3.8.0.Measurements (live ESPN, 8 leagues = ledpi's config, cold cache, alternating order)
The harness builds
SoccerScoreboardPlugin, runsupdate(), and waits for the background service to go quiet, countingHTTPAdapter.sendandgetaddrinfocalls. For the hourly figure, the clock is advanced an hour before each furtherupdate().Tests
New
test_schedule_fetched_once.py. It checks four things:Against the 2.39.2 code it fails 6 checks.
run_plugin_tests.pyfor soccer, football, baseball, hockey and basketball against core main and against #751 gives identical failure lists (10 pre-existing Windows failures); this branch adds one pass.These all pass with
LEDMATRIX_COREset:check_version_bump.py soccer-scoreboard,check_manifest_version_fields.py soccer-scoreboard,check_min_core_version,check_sports_drift,check_sports_helpers_parity,check_module_collisions,test_espn_dates_copiesandcheck_manifests_ascii.Overlap
The unmerged
claude/espn-canonical-scoreboard-keys(waiting for core 3.9.0) changes the same cache-key and cache-read lines in_fetch_soccer_api_data: canonical key plus_cached_schedule(cache_key, (legacy_key,)). It also bumps the same manifest and CHANGELOG. Whichever lands second needs a small rebase:_cached_scheduleread inside_cached_window;Not merging; for review.
🤖 Generated with Claude Code