Skip to content

Commit b02efbb

Browse files
committed
Fixed state file deadlock (#233)
* Fixed state file deadlock * Fixed pre-commit (cherry picked from commit f00a665)
1 parent e417f3e commit b02efbb

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

.github/workflows/helm_release.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
uses: actions/checkout@v3
1717
with:
1818
fetch-depth: 0
19-
19+
2020
- name: Configure Git
2121
run: |
2222
git config user.name "elimoshkovich"
@@ -30,4 +30,4 @@ jobs:
3030
env:
3131
CR_TOKEN: "${{ secrets.PAGES }}"
3232
with:
33-
skip_existing: true
33+
skip_existing: true

horizon/state.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)