diff --git a/src/background_data_service.py b/src/background_data_service.py index 1011a1f0..99e101a4 100644 --- a/src/background_data_service.py +++ b/src/background_data_service.py @@ -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