From 8f3e12c9b867fa435fa9c661b62afe5fa3ab5945 Mon Sep 17 00:00:00 2001 From: Paulus Schoutsen Date: Sat, 1 Oct 2016 15:42:17 -0700 Subject: [PATCH] Make Automation.reload_service_handler async --- homeassistant/components/automation/__init__.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/homeassistant/components/automation/__init__.py b/homeassistant/components/automation/__init__.py index 3142d759926..a677fe1da4e 100644 --- a/homeassistant/components/automation/__init__.py +++ b/homeassistant/components/automation/__init__.py @@ -164,13 +164,14 @@ def setup(hass, config): for entity in component.extract_from_service(service_call): yield from getattr(entity, method)() + @asyncio.coroutine def reload_service_handler(service_call): """Remove all automations and load new ones from config.""" - conf = component.prepare_reload() + conf = yield from hass.loop.run_in_executor( + None, component.prepare_reload) if conf is None: return - run_coroutine_threadsafe( - _async_process_config(hass, conf, component), hass.loop).result() + yield from _async_process_config(hass, conf, component) hass.services.register(DOMAIN, SERVICE_TRIGGER, trigger_service_handler, descriptions.get(SERVICE_TRIGGER),