@@ -197,6 +197,7 @@ async def _get_request(self, id: str) -> Request | None:
197197 if id in self ._requests_cache :
198198 return self ._requests_cache [id ]
199199
200+ # Requests that were not added by this client are not in local cache. Fetch them from platform.
200201 response = await self ._api_client .get_request (id )
201202
202203 if response is None :
@@ -206,13 +207,13 @@ async def _get_request(self, id: str) -> Request | None:
206207
207208 # Updated local caches
208209 if id in self ._requests_in_progress :
209- # Ignore requests that are already in progress, client is already aware of them.
210- self . _requests_already_handled . add ( id )
210+ # No caching of requests that are already in progress, client is already aware of them.
211+ pass
211212 elif request .was_already_handled :
212213 # Cache only id for already handled requests
213214 self ._requests_already_handled .add (id )
214215 else :
215- # Cache full request for unhandled requests that are not yet in progress
216+ # Cache full request for unhandled requests that are not yet in progress and are not yet handled.
216217 self ._requests_cache [id ] = request
217218 return request
218219
@@ -268,16 +269,9 @@ async def _list_head(self) -> None:
268269 if request .was_already_handled :
269270 # Do not cache fully handled requests, we do not need them. Just cache their id.
270271 self ._requests_already_handled .add (request_id )
271- else :
272- # Only fetch the request if we do not know it yet.
273- if request_id not in self ._requests_cache :
274- complete_request_data = await self ._api_client .get_request (request_id )
275- request = Request .model_validate (complete_request_data )
276- self ._requests_cache [request_id ] = request
277-
278- # Add new requests to the end of the head, unless already present in head
279- if request_id not in self ._head_requests :
280- self ._head_requests .appendleft (request_id )
272+ # Add new requests to the end of the head, unless already present in head
273+ elif request_id not in self ._head_requests :
274+ self ._head_requests .appendleft (request_id )
281275
282276 async def mark_request_as_handled (self , request : Request ) -> ProcessedRequest | None :
283277 """Mark a request as handled after successful processing.
0 commit comments