Use contextlib.suppress where possible (#48189)
This commit is contained in:
parent
9656f260a4
commit
6932cf9534
86 changed files with 238 additions and 398 deletions
|
@ -2,7 +2,7 @@
|
|||
from __future__ import annotations
|
||||
|
||||
import asyncio
|
||||
from contextlib import asynccontextmanager
|
||||
from contextlib import asynccontextmanager, suppress
|
||||
from datetime import datetime, timedelta
|
||||
from functools import partial
|
||||
import itertools
|
||||
|
@ -492,10 +492,8 @@ class _ScriptRun:
|
|||
async def async_cancel_long_task() -> None:
|
||||
# Stop long task and wait for it to finish.
|
||||
long_task.cancel()
|
||||
try:
|
||||
with suppress(Exception):
|
||||
await long_task
|
||||
except Exception: # pylint: disable=broad-except
|
||||
pass
|
||||
|
||||
# Wait for long task while monitoring for a stop request.
|
||||
stop_task = self._hass.async_create_task(self._stop.wait())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue