core/homeassistant/helpers
Phil Bruckner 5f5cb8bea8
Add support for simultaneous runs of Script helper - Part 2 (#32442)
* Add limit parameter to service call methods

* Break out prep part of async_call_from_config for use elsewhere

* Minor cleanup

* Fix improper use of asyncio.wait

* Fix state update

Call change listener immediately if its a callback

* Fix exception handling and logging

* Merge Script helper if_running/run_mode parameters into script_mode

- Remove background/blocking _ScriptRun subclasses which are no longer needed.

* Add queued script mode

* Disable timeout when making fully blocking script call

* Don't call change listener when restarting script

This makes restart mode behavior consistent with parallel & queue modes.

* Changes per review

- Call all script services (except script.turn_off) with no time limit.
- Fix handling of lock in _QueuedScriptRun and add comments to make it
  clearer how this code works.

* Changes per review 2

- Move cancel shielding "up" from _ScriptRun.async_run to Script.async_run
  (and apply to new style scripts only.) This makes sure Script class also
  properly handles cancellation which it wasn't doing before.
- In _ScriptRun._async_call_service_step, instead of using script.turn_off
  service, just cancel service call and let it handle the cancellation
  accordingly.

* Fix bugs

- Add missing call to change listener in Script.async_run
  in cancelled path.
- Cancel service task if ServiceRegistry.async_call cancelled.

* Revert last changes to ServiceRegistry.async_call

* Minor Script helper fixes & test improvements

- Don't log asyncio.CancelledError exceptions.
- Make change_listener a public attribute.
- Test overhaul
  - Parametrize tests.
  - Use common test functions.
  - Mock timeout so tests don't need to wait for real time to elapse.
  - Add common function for waiting for script action step.
2020-03-11 16:34:50 -07:00
..
__init__.py Type hint improvements (#31876) 2020-02-16 13:47:55 +01:00
aiohttp_client.py Revert "Use orjson to parse json faster (#32153)" (#32185) 2020-02-25 21:07:16 +01:00
area_registry.py Sort imports according to PEP8 for 'homeassistant' folder (#29789) 2019-12-09 16:42:10 +01:00
check_config.py Add Safe Mode (#30723) 2020-01-14 13:03:02 -08:00
collection.py Allow managing Lovelace storage dashboards (#32241) 2020-02-28 12:43:17 -08:00
condition.py Find related items scripts/automations (#31293) 2020-01-29 16:19:13 -08:00
config_entry_flow.py Sort imports according to PEP8 for 'homeassistant' folder (#29789) 2019-12-09 16:42:10 +01:00
config_entry_oauth2_flow.py Removes unneeded abort if unique id in Oauth2 discovery flow (#30733) 2020-01-13 05:29:19 -08:00
config_validation.py Improve script validation (#32461) 2020-03-05 11:44:42 -08:00
data_entry_flow.py Use new custom_serializer (#31871) 2020-02-15 15:36:57 -08:00
debounce.py Improve debounce cooldown (#32161) 2020-02-26 11:27:37 -08:00
deprecation.py Adds guards for missing information in call stack frames (#27217) 2019-10-05 11:59:33 +02:00
device_registry.py Allow sw_version update of a device registry entry. (#32630) 2020-03-11 09:31:02 -07:00
discovery.py Various string cleanups (#30435) 2020-01-03 14:47:06 +01:00
dispatcher.py Sort imports according to PEP8 for 'homeassistant' folder (#29789) 2019-12-09 16:42:10 +01:00
entity.py Add MQTT WS command to remove device (#31989) 2020-02-24 20:46:02 -08:00
entity_component.py Annotate more async functions correctly (#31802) 2020-02-14 10:00:22 -08:00
entity_platform.py Entity Registry to store and restore name/icon (#31714) 2020-02-11 09:40:50 -08:00
entity_registry.py Coronavirus updates (#32417) 2020-03-02 17:59:32 -08:00
entity_values.py Migrate legacy typehints in core to PEP-526 (#26403) 2019-09-03 20:36:04 -07:00
entityfilter.py Black 2019-07-31 12:25:30 -07:00
event.py Update Hue data fetching (#31338) 2020-01-31 14:47:40 -08:00
icon.py Various string cleanups (#30435) 2020-01-03 14:47:06 +01:00
integration_platform.py Add integration platform helper (#29914) 2019-12-13 15:38:41 +01:00
intent.py Various string cleanups (#30435) 2020-01-03 14:47:06 +01:00
json.py Black 2019-07-31 12:25:30 -07:00
location.py Type 2019-07-31 13:08:31 -07:00
logging.py Fix typos found by codespell (#31243) 2020-01-31 08:33:00 -08:00
network.py Sort imports according to PEP8 for 'homeassistant' folder (#29789) 2019-12-09 16:42:10 +01:00
restore_state.py Helpers typing improvements (#31865) 2020-02-15 13:03:53 -08:00
script.py Add support for simultaneous runs of Script helper - Part 2 (#32442) 2020-03-11 16:34:50 -07:00
service.py Add support for simultaneous runs of Script helper - Part 2 (#32442) 2020-03-11 16:34:50 -07:00
signal.py Sort imports according to PEP8 for 'homeassistant' folder (#29789) 2019-12-09 16:42:10 +01:00
state.py Sort imports according to PEP8 for 'homeassistant' folder (#29789) 2019-12-09 16:42:10 +01:00
storage.py Allow managing Lovelace storage dashboards (#32241) 2020-02-28 12:43:17 -08:00
sun.py Sort imports according to PEP8 for 'homeassistant' folder (#29789) 2019-12-09 16:42:10 +01:00
system_info.py Show kernel version on linux (#32276) 2020-02-27 13:59:30 -08:00
temperature.py Sort imports according to PEP8 for 'homeassistant' folder (#29789) 2019-12-09 16:42:10 +01:00
template.py Helpers typing improvements (#31865) 2020-02-15 13:03:53 -08:00
translation.py Various string cleanups (#30435) 2020-01-03 14:47:06 +01:00
typing.py Sort imports according to PEP8 for 'homeassistant' folder (#29789) 2019-12-09 16:42:10 +01:00
update_coordinator.py Update error handling in update coordinator (#32452) 2020-03-04 08:05:46 -08:00