Switch shell_command to use async_timeout instead of asyncio.wait_for (#88573)
This avoids creating a task every time
This commit is contained in:
parent
cbba0fee42
commit
e54eb7e2c8
1 changed files with 3 additions and 3 deletions
|
@ -6,6 +6,7 @@ from contextlib import suppress
|
|||
import logging
|
||||
import shlex
|
||||
|
||||
import async_timeout
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant.core import HomeAssistant, ServiceCall
|
||||
|
@ -82,9 +83,8 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
|
|||
|
||||
process = await create_process
|
||||
try:
|
||||
stdout_data, stderr_data = await asyncio.wait_for(
|
||||
process.communicate(), COMMAND_TIMEOUT
|
||||
)
|
||||
async with async_timeout.timeout(COMMAND_TIMEOUT):
|
||||
stdout_data, stderr_data = await process.communicate()
|
||||
except asyncio.TimeoutError:
|
||||
_LOGGER.exception(
|
||||
"Timed out running command: `%s`, after: %ss", cmd, COMMAND_TIMEOUT
|
||||
|
|
Loading…
Add table
Reference in a new issue