Skip to content

Limit service description loading to a single thread#11733

Merged
balloob merged 1 commit into
home-assistant:devfrom
amelchio:services-yaml-one-thread
Jan 19, 2018
Merged

Limit service description loading to a single thread#11733
balloob merged 1 commit into
home-assistant:devfrom
amelchio:services-yaml-one-thread

Conversation

@amelchio
Copy link
Copy Markdown
Contributor

Description:

With #11479 we started loading all required services.yaml files concurrently. The idea was that one file could be parsed while the next one was loaded from disk. However, this has turned out to be too taxing on slow hardware like the Raspberry Pi and timer synchronization problems can result:

2018-01-17 17:50:04 ERROR (MainThread) [homeassistant.core] Timer got out of sync. Resetting
2018-01-17 17:50:09 ERROR (MainThread) [homeassistant.core] Timer got out of sync. Resetting

This PR reworks the loading to all happen in a single thread, hopefully leaving room for the rest of Home Assistant to do its tasks.

Related issue (if applicable): fixes # (none yet)

Checklist:

  • The code change is tested and works locally.

If the code does not interact with devices:

  • Local tests with tox run successfully.
  • Tests have been added to verify that the new code works.

if loading_tasks:
yield from asyncio.wait(loading_tasks, loop=hass.loop)
if missing:
loaded = yield from hass.async_add_job(load_services_files, missing)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems to no longer use the YAML cache?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We cache needed descriptions in description_cache = hass.data[SERVICE_DESCRIPTION_CACHE] but the complete YAML file is discarded because it can contain many descriptions that we do not need.

That has not changed with this PR. However, apparently I got confused during the multiple reworks of the original PR and named yaml_cache poorly so now I renamed it.

@balloob balloob merged commit ce9673b into home-assistant:dev Jan 19, 2018
@balloob balloob mentioned this pull request Jan 26, 2018
@home-assistant home-assistant locked and limited conversation to collaborators May 29, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants