Skip to content

Use a single service browser for zeroconf discovery#35997

Merged
MartinHjelmare merged 3 commits intohome-assistant:devfrom
bdraco:single_browser
May 23, 2020
Merged

Use a single service browser for zeroconf discovery#35997
MartinHjelmare merged 3 commits intohome-assistant:devfrom
bdraco:single_browser

Conversation

@bdraco
Copy link
Copy Markdown
Member

@bdraco bdraco commented May 22, 2020

Proposed change

Currently we start a service browser thread for every
zeroconf type. Support was added to upstream
python-zeroconf to allow a single service browser to
listen for multiple types.

This solves the problem where each new integration that
is discovered by zeroconf requires another thread and
has to process the incoming data another time which
did not scale.

Additionally, the upstream changes include a fix for a zeroconf
race condition that takes down the service.

Upstream changes
Race Fix: python-zeroconf/python-zeroconf@24a0619
Service Browsers: python-zeroconf/python-zeroconf@a6ad100

Type of change

  • Dependency upgrade
  • Bugfix (non-breaking change which fixes an issue)
  • New integration (thank you!)
  • New feature (which adds functionality to an existing integration)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Example entry for configuration.yaml:

# Example configuration.yaml

Additional information

  • This PR fixes or closes issue: fixes #
  • This PR is related to issue:
  • Link to documentation pull request:

Checklist

  • The code change is tested and works locally.
  • Local tests pass. Your PR cannot be merged unless tests pass
  • There is no commented out code in this PR.
  • I have followed the development checklist
  • The code has been formatted using Black (black --fast homeassistant tests)
  • Tests have been added to verify that the new code works.

If user exposed functionality or configuration variables are added/changed:

If the code communicates with devices, web services, or third-party tools:

  • The manifest file has all fields filled out correctly.
    Updated and included derived files by running: python3 -m script.hassfest.
  • New or updated dependencies have been added to requirements_all.txt.
    Updated by running python3 -m script.gen_requirements_all.
  • Untested files have been added to .coveragerc.

The integration reached or maintains the following Integration Quality Scale:

  • No score or internal
  • 🥈 Silver
  • 🥇 Gold
  • 🏆 Platinum

Currently we start a service browser thread for every
zeroconf type. Support was added to upstream
python-zeroconf to allow a single service browser to
listen for multiple types.

This solves the problem where each new integration that
is discovered by zeroconf requires another thread and
has to process the incoming data another time which
did not scale.
@bdraco bdraco added the dependency-bump Pull requests that update a dependency file label May 22, 2020
@ctalkington
Copy link
Copy Markdown
Contributor

ctalkington commented May 22, 2020

is there queuing for incoming responses? just wonder if we need to balance the threads out so that we dont overwhelm a single thread.

@bdraco
Copy link
Copy Markdown
Member Author

bdraco commented May 22, 2020

    Found library python3 : True
    fetching https://raw.githubusercontent.com/home-assistant/python-openzwave/hass/archives/open-zwave-hass-0.1.10.zip into openzwave-embed/open-zwave.zip for version 0.1.10
    error: HTTP Error 500: Internal Server Error

@bdraco
Copy link
Copy Markdown
Member Author

bdraco commented May 22, 2020

/AzurePipelines Run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

@bdraco
Copy link
Copy Markdown
Member Author

bdraco commented May 22, 2020

@ctalkington Everything goes into a callback queue so it should be fine
python-zeroconf/python-zeroconf@a6ad100#diff-c412a849f8b1319f3f8b0e0c13b83f0fR1460

Comment thread homeassistant/components/zeroconf/__init__.py Outdated
@MartinHjelmare MartinHjelmare merged commit b057801 into home-assistant:dev May 23, 2020
@bdraco bdraco linked an issue May 24, 2020 that may be closed by this pull request
@emontnemery emontnemery added this to the 0.110.4 milestone May 28, 2020
@emontnemery
Copy link
Copy Markdown
Contributor

Added to 0.110.4: #36185 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cherry-picked cla-signed core dependency-bump Pull requests that update a dependency file integration: zeroconf small-pr PRs with less than 30 lines.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

zeroconf: Exception during startup

8 participants