8000 Helpers.Script should cache condition · Issue #3629 · home-assistant/core · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Helpers.Script should cache condition #3629

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

Closed
balloob opened this issue Oct 1, 2016 · 0 comments · Fixed by #3797
Closed

Helpers.Script should cache condition #3629

balloob opened this issue Oct 1, 2016 · 0 comments · Fixed by #3797

Comments

@balloob
Copy link
Member
balloob commented Oct 1, 2016

Home Assistant release (hass --version): 0.29.5
Python release (python3 --version): All
Component/platform: homeassistant.helpers.script
Description of problem:

When we're running a script, we will always construct a new condition from the config. This should be cached on the Script instance instead.

Fix should also include

  • test running the same script twice and making sure condition.async_from_config is only called once.
  • test that includes two conditions, making sure both are getting cached

Constructing new condition from config code

balloob pushed a commit that referenced this issue Oct 11, 2016
* Cache condition in helpers.Script

The caching is a simple in-memory, per-instance dictionary.
We use __str__ to format cache keys.

This naive implementation has some disadvantages (e.g., we won't be able
to cache two conditions that contain references to
distinct-but-equivalent object instances and we don't have any control
over the size of the condition cache), but for most simple use-cases the
approach should be good enough.

Resolves #3629

* Fix docstring style
@home-assistant home-assistant 50D3 locked and limited conversation to collaborators Mar 17, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant
0