Fix google_mail doing blocking I/O in the event loop (#118421)

fixes #118411
This commit is contained in:
J. Nick Koston 2024-05-29 09:55:12 -10:00 committed by GitHub
parent 43ceb1c6c8
commit 9e9e1f75f2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1,5 +1,6 @@
"""API for Google Tasks bound to Home Assistant OAuth."""
from functools import partial
import json
import logging
from typing import Any
@ -52,7 +53,9 @@ class AsyncConfigEntryAuth:
async def _get_service(self) -> Resource:
"""Get current resource."""
token = await self.async_get_access_token()
return build("tasks", "v1", credentials=Credentials(token=token))
return await self._hass.async_add_executor_job(
partial(build, "tasks", "v1", credentials=Credentials(token=token))
)
async def list_task_lists(self) -> list[dict[str, Any]]:
"""Get all TaskList resources."""