Fix google calendar blocking call, running outside of executor (#68948)

This commit is contained in:
Allen Porter 2022-03-31 04:22:33 -07:00 committed by GitHub
parent 4327d3aef9
commit 3c478c312a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -183,9 +183,13 @@ class GoogleCalendarService:
"""Get the calendar service with valid credetnails."""
await self._session.async_ensure_token_valid()
creds = _async_google_creds(self._hass, self._session.token)
return google_discovery.build(
"calendar", "v3", credentials=creds, cache_discovery=False
)
def _build() -> google_discovery.Resource:
return google_discovery.build(
"calendar", "v3", credentials=creds, cache_discovery=False
)
return await self._hass.async_add_executor_job(_build)
async def async_list_calendars(
self,