From b2c33c13732b00b56b4efe89e66c9f05130ade12 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Sat, 17 Apr 2021 22:04:45 -1000 Subject: [PATCH] Only fetch the local ip once per run (#49336) Wrap get_local_ip in lru_cache --- homeassistant/util/__init__.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/homeassistant/util/__init__.py b/homeassistant/util/__init__.py index 79ceeada0c2..c684d14d276 100644 --- a/homeassistant/util/__init__.py +++ b/homeassistant/util/__init__.py @@ -4,7 +4,7 @@ from __future__ import annotations import asyncio from datetime import datetime, timedelta import enum -from functools import wraps +from functools import lru_cache, wraps import random import re import socket @@ -129,6 +129,7 @@ def ensure_unique_string( # Taken from: http://stackoverflow.com/a/11735897 +@lru_cache(maxsize=None) def get_local_ip() -> str: """Try to determine the local IP address of the machine.""" try: