Black
This commit is contained in:
parent
da05dfe708
commit
4de97abc3a
2676 changed files with 163166 additions and 140084 deletions
|
@ -15,7 +15,8 @@ _LOGGER = logging.getLogger(__name__)
|
|||
@bind_hass
|
||||
def async_register_signal_handling(hass: HomeAssistant) -> None:
|
||||
"""Register system signal handler for core."""
|
||||
if sys.platform != 'win32':
|
||||
if sys.platform != "win32":
|
||||
|
||||
@callback
|
||||
def async_signal_handle(exit_code: int) -> None:
|
||||
"""Wrap signal handling.
|
||||
|
@ -28,20 +29,19 @@ def async_register_signal_handling(hass: HomeAssistant) -> None:
|
|||
hass.async_create_task(hass.async_stop(exit_code))
|
||||
|
||||
try:
|
||||
hass.loop.add_signal_handler(
|
||||
signal.SIGTERM, async_signal_handle, 0)
|
||||
hass.loop.add_signal_handler(signal.SIGTERM, async_signal_handle, 0)
|
||||
except ValueError:
|
||||
_LOGGER.warning("Could not bind to SIGTERM")
|
||||
|
||||
try:
|
||||
hass.loop.add_signal_handler(
|
||||
signal.SIGINT, async_signal_handle, 0)
|
||||
hass.loop.add_signal_handler(signal.SIGINT, async_signal_handle, 0)
|
||||
except ValueError:
|
||||
_LOGGER.warning("Could not bind to SIGINT")
|
||||
|
||||
try:
|
||||
hass.loop.add_signal_handler(
|
||||
signal.SIGHUP, async_signal_handle, RESTART_EXIT_CODE)
|
||||
signal.SIGHUP, async_signal_handle, RESTART_EXIT_CODE
|
||||
)
|
||||
except ValueError:
|
||||
_LOGGER.warning("Could not bind to SIGHUP")
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue