-
-
Notifications
You must be signed in to change notification settings - Fork 33.7k
Better locking while setting up components + discovery #4463
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
Conversation
@@ -1,7 +1,10 @@ | |||
"""Test discovery helpers.""" | |||
import asyncio |
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.
'asyncio' imported but unused
3023f03
to
5d40e12
Compare
# Convert values to dictionaries if they are None | ||
config = defaultdict( | ||
dict, {key: value or {} for key, value in config.items()}) | ||
new_config = OrderedDict() |
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 always thought that we setup everything with an ordered dict but looks like I was wrong. Instead we converted everything to a normal dictionary, making each setup unpredictable.
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.
Nice! One typo in a docstring.
What about the lock here:
https://github.com/home-assistant/home-assistant/blob/5d40e12639e71467584a467a7f2fc3e8e8bf691d/homeassistant/bootstrap.py#L98-L177
Do we still need that?
There are two different types of discoveries that can be fired/listened for. | ||
- listen/discover is for services. These are targetted at a component. | ||
- listen_platform/discover_platform is for platforms. These are used by | ||
components to allow discovery of their platofrms. |
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.
platofrms -> platforms
For now we will still need that that lock in case people do not use the |
Description:
This improves locking to avoid running parallel component setups during startup and discovery.
Related issue (if applicable): #4435 #4014
Checklist:
If the code does not interact with devices:
tox
run successfully. Your PR cannot be merged unless tests pass