Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions homeassistant/helpers/script.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""Helpers to execute scripts."""

import logging
from contextlib import suppress
from itertools import islice
from typing import Optional, Sequence

Expand Down Expand Up @@ -95,7 +96,9 @@ async def async_run(self, variables: Optional[Sequence] = None,
def async_script_delay(now):
"""Handle delay."""
# pylint: disable=cell-var-from-loop
self._async_remove_listener()
with suppress(ValueError):
self._async_listener.remove(unsub)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use suppress

self.hass.async_create_task(
self.async_run(variables, context))

Expand Down Expand Up @@ -240,7 +243,8 @@ def _async_set_timeout(self, action, variables, context,
@callback
def async_script_timeout(now):
"""Call after timeout is retrieve."""
self._async_remove_listener()
with suppress(ValueError):
self._async_listener.remove(unsub)

# Check if we want to continue to execute
# the script after the timeout
Expand Down