Skip to content

fix(ps): robust manifest parsing and clean asyncio teardown - #244

Merged
gilesknap merged 1 commit into
mainfrom
fix-yaml-parsing
May 26, 2026
Merged

gilesknap merged 1 commit into
mainfrom
fix-yaml-parsing

Conversation

@gilesknap

Copy link
Copy Markdown
Member

argocd's --source live output can contain documents with no kind key, or --- appearing inside values, which broke the naive split("---") parser with KeyError: 'kind' and ParserError. Switch to YAML.load_all() and guard against non-resource docs.

Separately, _run_async was calling asyncio.run(), which closes the loop on exit. asyncio.Process / subprocess transports hold a reference cycle back to the loop, so their __del__ runs in a later GC pass and prints Event loop is closed /
Loop ... that handles pid X is closed spam. Own the loop explicitly and force gc.collect() before closing so finalizers run against a live loop.

argocd's `--source live` output can contain documents with no `kind`
key, or `---` appearing inside values, which broke the naive
`split("---")` parser with `KeyError: 'kind'` and `ParserError`.
Switch to `YAML.load_all()` and guard against non-resource docs.

Separately, `_run_async` was calling `asyncio.run()`, which closes
the loop on exit. asyncio.Process / subprocess transports hold a
reference cycle back to the loop, so their `__del__` runs in a
later GC pass and prints `Event loop is closed` /
`Loop ... that handles pid X is closed` spam. Own the loop
explicitly and force `gc.collect()` before closing so finalizers
run against a live loop.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@gilesknap
gilesknap merged commit 51703ca into main May 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant