Remove warning on script delay (#17264)

* Remove warning on script delay

* Use suppress
This commit is contained in:
Anders Melchiorsen 2018-10-09 10:06:42 +02:00 committed by Paulus Schoutsen
parent 540d22d603
commit 5db7d702c8

View File

@ -1,6 +1,7 @@
"""Helpers to execute scripts.""" """Helpers to execute scripts."""
import logging import logging
from contextlib import suppress
from itertools import islice from itertools import islice
from typing import Optional, Sequence from typing import Optional, Sequence
@ -95,7 +96,9 @@ class Script():
def async_script_delay(now): def async_script_delay(now):
"""Handle delay.""" """Handle delay."""
# pylint: disable=cell-var-from-loop # pylint: disable=cell-var-from-loop
self._async_remove_listener() with suppress(ValueError):
self._async_listener.remove(unsub)
self.hass.async_create_task( self.hass.async_create_task(
self.async_run(variables, context)) self.async_run(variables, context))
@ -240,7 +243,8 @@ class Script():
@callback @callback
def async_script_timeout(now): def async_script_timeout(now):
"""Call after timeout is retrieve.""" """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 # Check if we want to continue to execute
# the script after the timeout # the script after the timeout