mirror of
https://github.com/ChuckBuilds/LEDMatrix.git
synced 2026-10-10 17:16:36 +00:00
Compare commits
2
Commits
e765dd20c9
...
e26dff149e
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e26dff149e | ||
|
|
f7e5a6a4d0 |
@@ -46,10 +46,9 @@ ESPN_MAX_LIMIT = 500
|
||||
# How long a rejected range keeps later ranges from being tried as ranges.
|
||||
RANGE_RETRY_SECONDS = 6 * 60 * 60
|
||||
|
||||
# How many chunk requests may be in flight at once. A cold college-baseball
|
||||
# season is ~130 chunks once the busy months are re-asked day by day; asking
|
||||
# for them one at a time took long enough that scoreboard plugins blew the
|
||||
# 20s update() timeout on first run. Kept under requests' default
|
||||
# How many chunk requests may be in flight at once. Four busy months of
|
||||
# college baseball are ~130 chunks once each is re-asked day by day: 17.7s one
|
||||
# at a time on a Pi 4, 2.6-3.3s six at a time. Kept under requests' default
|
||||
# pool_maxsize of 10 so the shared Session never has to discard connections.
|
||||
ESPN_CHUNK_WORKERS = 6
|
||||
|
||||
@@ -272,9 +271,10 @@ def fetch_espn_date_chunks(
|
||||
|
||||
# A month that came back at the cap is truncated; its days replace it in
|
||||
# place, so merged events stay in chunk order however the requests raced.
|
||||
slots: List[Any] = list(results)
|
||||
slots: List[Any] = results
|
||||
capped: Dict[int, List[str]] = {}
|
||||
for index, (chunk, payload) in enumerate(zip(chunks, results)):
|
||||
for index, chunk in enumerate(chunks):
|
||||
payload = slots[index]
|
||||
if payload is None or len(chunk) != 6:
|
||||
continue
|
||||
events = payload.get("events") if isinstance(payload, dict) else None
|
||||
@@ -285,6 +285,13 @@ def fetch_espn_date_chunks(
|
||||
chunk, ESPN_MAX_LIMIT,
|
||||
)
|
||||
capped[index] = _days_of_month(chunk)
|
||||
# Drop the truncated month now rather than after its days arrive:
|
||||
# a capped college-baseball month is ~2MB of parsed JSON, and
|
||||
# holding four of them through ~120 day requests added ~25MB to
|
||||
# the peak -- more than the concurrency itself. Low-memory boards
|
||||
# (docs/LOW_MEMORY_BOARDS.md) have under 200MB of headroom.
|
||||
slots[index] = None
|
||||
payload = events = None
|
||||
|
||||
if capped:
|
||||
days = [day for index in sorted(capped) for day in capped[index]]
|
||||
|
||||
Reference in New Issue
Block a user