New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use the shared zeroconf instance when attempting to create another Zeroconf instance #38744
Use the shared zeroconf instance when attempting to create another Zeroconf instance #38744
Conversation
Is it possible to get what file or class initiates this second zeroconf instance? |
The warning contains that. I'll make sure to keep that when I rework it. |
If the code runs in the executor we won't have enough stack to figure out which integration
Probably better to log the stack in that case instead |
Here is what we report when we can't figure out the integration. I couldn't figure out a way to get the integration when the code is running in the executor since we don't have the stack that created the executor job so I figured a traceback was the best for now
|
Still seeing multiple instances |
|
||
|
||
def install_multiple_zeroconf_warning() -> None: | ||
"""Wrap the Zeroconf class to warn if multiple instances are detected.""" | ||
def install_multiple_zeroconf_catcher(zc) -> None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should make sure that we don't call this method in any of the tests. I think that we should put something like this in tests/conftest.py
:
from homeassistant.components.zeroconf import usage
usage.orig_install_multiple_zeroconf_catcher = usage.install_multiple_zeroconf_catcher
usage.install_multiple_zeroconf_catcher = lambda zc: None
And then write the tests against the orig_
function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I re-arranged the tests, added conftest, and test_usage. Hopefully that was what you were looking for. 🤞
Type of change
Multiple Zeroconf instances keep causing us problems and reports of
high cpu usage. Log when they are created.
#38248 (comment)
https://community.home-assistant.io/t/high-cpu-usage-after-0-113/214655/30
If an integration attempts to create another instance, we now provide them the shared
instance, and log.
Note: esphome is the last known integration in core that still does this and it is fixed here #38747
Example entry for
configuration.yaml
:# Example configuration.yaml
Additional information
Checklist
black --fast homeassistant tests
)If user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
Updated and included derived files by running:
python3 -m script.hassfest
.requirements_all.txt
.Updated by running
python3 -m script.gen_requirements_all
..coveragerc
.The integration reached or maintains the following Integration Quality Scale: