Skip to content

Conversation

wjnelson78
Copy link

…r_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.

…r_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.
@wjnelson78
Copy link
Author

FYI - This change for me allows HA to restart much faster than before.

@dgomes
Copy link
Collaborator

dgomes commented Mar 11, 2025

This had already been addressed through an executer task (I have no warnings)

Also too many unrelated changes

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.

2 participants