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 Franck Nijhof
parent 1e77a59561
commit 0d4990799f
No known key found for this signature in database
GPG Key ID: D62583BA8AB11CA3

View File

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