From fb985e2909d8ffc5b7927af9b7c95a88a63ea21a Mon Sep 17 00:00:00 2001 From: Anders Melchiorsen Date: Tue, 20 Feb 2018 12:37:01 +0100 Subject: [PATCH] Build JSON in executor (#12536) --- homeassistant/components/history.py | 9 ++++++--- homeassistant/components/logbook.py | 3 ++- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/homeassistant/components/history.py b/homeassistant/components/history.py index efcbb50a447..dd14bbf6811 100644 --- a/homeassistant/components/history.py +++ b/homeassistant/components/history.py @@ -303,8 +303,10 @@ class HistoryPeriodView(HomeAssistantView): entity_ids = entity_ids.lower().split(',') include_start_time_state = 'skip_initial_state' not in request.query - result = yield from request.app['hass'].async_add_job( - get_significant_states, request.app['hass'], start_time, end_time, + hass = request.app['hass'] + + result = yield from hass.async_add_job( + get_significant_states, hass, start_time, end_time, entity_ids, self.filters, include_start_time_state) result = result.values() if _LOGGER.isEnabledFor(logging.DEBUG): @@ -327,7 +329,8 @@ class HistoryPeriodView(HomeAssistantView): sorted_result.extend(result) result = sorted_result - return self.json(result) + response = yield from hass.async_add_job(self.json, result) + return response class Filters(object): diff --git a/homeassistant/components/logbook.py b/homeassistant/components/logbook.py index 9e1e2e54ad9..b3477099918 100644 --- a/homeassistant/components/logbook.py +++ b/homeassistant/components/logbook.py @@ -136,7 +136,8 @@ class LogbookView(HomeAssistantView): events = yield from hass.async_add_job( _get_events, hass, self.config, start_day, end_day) - return self.json(events) + response = yield from hass.async_add_job(self.json, events) + return response class Entry(object):