libdyson-wg / ha-dyson

Home Assistant custom integration for Wi-Fi connected Dyson devices
MIT License
208 stars 23 forks source link

HA core beta 2024.3 log message `loaded_executor` event loop blocking #138

Closed Anto79-ops closed 4 months ago

Anto79-ops commented 4 months ago

hello Ben!

3 times a charm?

Just installed HA 2024.3 core beta, and when enabling this logging in config.yaml,

logger:
  default: info
  logs:
    homeassistant.loader: debug

acording bdraco, there is some event loop blocking for this integration from the following:

2024-02-28 15:44:10.065 DEBUG (MainThread) [homeassistant.loader] Component dyson_local import took 0.314 seconds (loaded_executor=False)

The loaded_executor issue is Importing X blocks the event loop for 0.949 seconds

CC'ed @bdraco if you need more information

bdraco commented 4 months ago

The solution is to add "import_executor": "true" to the manifest.json

Anto79-ops commented 4 months ago

just wanted to confirm, I can manually add this to the file, but wanted to make sure it looks good here

{
    "domain": "dyson_local",
    "name": "Dyson",
    "codeowners": ["@libdyson-wg", "@dotvezz"],
    "config_flow": true,
    "dependencies": ["zeroconf"],
    "documentation": "https://github.com/libdyson-wg/ha-dyson",
    "iot_class": "local_push",
    "issue_tracker": "https://github.com/libdyson-wg/ha-dyson/issues",
    "requirements": ["paho-mqtt"],
    "version": "1.3.10",
    "import_executor": "true"
}
dotvezz commented 4 months ago

If that fixes it for you, make a PR :smile:

Anto79-ops commented 4 months ago

lol ok, will let you know in about 1 hour

Anto79-ops commented 4 months ago

so good news, Dyson didn't blow up when I made the modication as per above.

these are logs I was able to extract now:

2024-02-29 13:56:39.322 DEBUG (MainThread) [homeassistant.loader] Component dyson_local import took 10.232 seconds (loaded_executor=True)
2024-02-29 13:56:39.324 INFO (MainThread) [homeassistant.setup] Setting up dyson_local
2024-02-29 13:56:39.325 INFO (MainThread) [homeassistant.setup] Setup of domain dyson_local took 0.0 seconds
2024-02-29 13:56:45.774 DEBUG (MainThread) [homeassistant.loader] Importing platform dyson_local.config_flow took 0.00s (loaded_executor=False)

these are the times now.

From what I understand, its not blocking the event loop anymore, instead its just waiting (that 10.232 seconds), but, this is system dependent now.

So, overall, the "import_executor": "true", should have a positive effect

I'm not pretending to be a dev here...lol

bdraco commented 4 months ago

Right, the import is running at another thread now so the event loop continues to do its job and everything in Home Assistant doesn't stop to wait for the import