@@ -98,7 +98,6 @@ async def update_state(self) -> AsyncGenerator[PersistentState, None]:
9898 prev_state = self ._state
9999 try :
100100 async with self ._write_lock :
101- await asyncio .gather (* self ._tasks )
102101 new_state = self ._state .copy ()
103102 yield new_state
104103 try :
@@ -196,13 +195,15 @@ def build_state_payload_sync(cls) -> dict:
196195 return payload
197196
198197 async def _report (self , state : PersistentState | None = None ):
198+ if state is not None :
199+ self ._state = state .copy ()
199200 config_url = f"{ sidecar_config .CONTROL_PLANE } { sidecar_config .REMOTE_STATE_ENDPOINT } "
200201 async with aiohttp .ClientSession () as session :
201202 logger .info ("Reporting status update to server..." )
202203 response = await session .post (
203204 url = config_url ,
204205 headers = {"Authorization" : f"Bearer { self ._env_api_key } " },
205- json = await PersistentStateHandler .build_state_payload (state ),
206+ json = await PersistentStateHandler .build_state_payload (),
206207 )
207208 if response .status != status .HTTP_204_NO_CONTENT :
208209 logger .warning (
@@ -213,9 +214,7 @@ async def _report(self, state: PersistentState | None = None):
213214
214215 async def seen_sdk (self , sdk : str ):
215216 if sdk not in self ._state .seen_sdks :
216- # ensure_future is expensive, only call it if actually needed
217- async with self ._write_lock :
218- self ._tasks .append (asyncio .create_task (self ._report_seen_sdk (sdk )))
217+ await self ._report_seen_sdk (sdk )
219218
220219 async def _report_seen_sdk (self , sdk : str ):
221220 async with self ._seen_sdk_update_lock :
0 commit comments