macsome_18 #58

Merged
neerdoc merged 2 commits from macsome_18 into main 2026-08-03 13:48:50 +00:00
Owner
No description provided.
HA's own blocking-call detector caught this live: sync_wishlist_playlist()
runs directly on the event loop (unlike match_and_build, which is already
dispatched to an executor thread), and _open_debug_log()'s open() call —
plus every _debug() write/flush after it, including from _apple_resolve_uri
and _wait_for_background_task which it calls — is blocking file I/O
happening straight on that loop.

Added _MemDebugLog, a drop-in stand-in for the real file handle that
buffers lines in memory instead (duck-types the .write()/.flush() _debug()
calls), and _write_debug_log() to do the one real disk write via
run_in_executor at the end of the async run. match_and_build and
fill_missing_album_tracks are unaffected — both already run off the event
loop via hass.async_add_executor_job, so their direct _open_debug_log()
file handles are fine as-is.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Pure reorganization, no behavior change: every function/constant moved
verbatim (verified via a normalized line-diff against the pre-split file —
only difference found was a docstring wording tweak and one dropped type
hint on a function signature) and via a real import + functional smoke
test of the split module graph (Track/MAPlaylist construction, _key(),
_buylist() against a throwaway sqlite db, MusicBrainz artist-credit
flattening).

  debug_log.py    — per-run diagnostic log files (_open_debug_log, _debug,
                    _MemDebugLog, _write_debug_log)
  models.py       — Track, MAPlaylist
  store.py        — the "wanted" SQLite store and buy-list derivation
  plex_match.py   — matching a Track against the Plex library
  qobuz.py        — Qobuz catalogue search and wishlist push
  musicbrainz.py  — album gap-fill via MusicBrainz release tracklists
  ma_client.py    — Music Assistant websocket client (async)
  engine.py       — match_and_build (the orchestrator) + a facade
                    re-exporting every submodule's public API, so
                    coordinator.py/button.py/__init__.py keep working
                    unchanged via `engine.whatever(...)`

engine.py: 1766 lines -> 200. Every external call site (grepped for every
`engine.X` reference across the integration) still resolves through the
facade — no caller needed to change.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
WulfScience-FOSS/ha-music-own!58
No description provided.