Commit 8cd3a1f
authored
Fix blocking open() calls by offloading file I/O to async_add_executor_job
In `__init__.py`, direct open() calls were being made on the Home Assistant event loop, leading to “Detected blocking call to open()” warnings and potential performance issues.
To address this:
- Moved the reading of `pages_schema.json` out of the constructor and into `async_added_to_hass`, wrapping the file read with `hass.async_add_executor_job()`.
- Introduced small synchronous helper functions (`_sync_read_json`, `_sync_read_text`, etc.) for file I/O. These are called inside `async_add_executor_job()`, preventing the main loop from blocking.
- Updated `async_load_page` to use the same pattern for JSON or text lines, validating JSON data against the pre-loaded schema.
- Ensures compliance with Home Assistant’s async guidelines and avoids blocking the event loop with disk I/O.
- Improves overall responsiveness and prevents related warnings in the HA logs.1 parent 4218153 commit 8cd3a1f
1 file changed
Lines changed: 179 additions & 238 deletions
0 commit comments