Skip to content

Snapshot FTMS callback state before diffing#69

Open
michaelw wants to merge 1 commit into
dudanov:mainfrom
michaelw:mw/upstream-pyftms-concurrency-snapshots
Open

Snapshot FTMS callback state before diffing#69
michaelw wants to merge 1 commit into
dudanov:mainfrom
michaelw:mw/upstream-pyftms-concurrency-snapshots

Conversation

@michaelw

Copy link
Copy Markdown

Summary

  • snapshot public properties/settings mappings before returning read-only views
  • snapshot realtime update state before zero filtering and diffing
  • use a local sentinel diff so callback payloads are built only from stable current data

Why

This is a defensive concurrency hardening change. The previous mapping proxies and updater diff code could expose or iterate live mutable dictionaries while callbacks or notification handling were still updating them. Returning snapshots and diffing copied state prevents retained views and callback payloads from changing underneath callers.

Tests

  • hassio-dev exec uv run --project repos/python-pyftms --python 3.13 pytest repos/python-pyftms/tests/test_manager.py repos/python-pyftms/tests/test_updater.py
  • hassio-dev exec uv run --project repos/python-pyftms --python 3.13 pytest repos/python-pyftms/tests

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