mirror of
https://github.com/ChuckBuilds/LEDMatrix.git
synced 2026-08-23 19:38:13 +00:00
fix(memory): file the cache-hit result before running its callback
Restores the original ordering. Releasing the payload after the callback meant filing the result after it too, so a callback that queried get_result() or is_request_complete() for its own request would not have found it -- a behaviour change unrelated to the memory fix. The dict holds a reference to the same object, so releasing after filing still clears the payload. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
@@ -199,6 +199,12 @@ class BackgroundDataService:
|
||||
cached=True,
|
||||
fetch_time=0.0
|
||||
)
|
||||
# Filed before the callback runs, as it always was: a callback
|
||||
# that queries get_result()/is_request_complete() for its own
|
||||
# request must still find it. Releasing afterwards mutates the
|
||||
# same object the dict holds.
|
||||
self.completed_requests[request_id] = result
|
||||
|
||||
if callback:
|
||||
try:
|
||||
callback(result)
|
||||
@@ -206,8 +212,6 @@ class BackgroundDataService:
|
||||
logger.error(f"Error in callback for request {request_id}: {e}")
|
||||
self._release_payload(result)
|
||||
|
||||
self.completed_requests[request_id] = result
|
||||
|
||||
logger.debug(f"Cache hit for {sport} {year} data")
|
||||
return request_id
|
||||
|
||||
|
||||
Reference in New Issue
Block a user