Only fetch the local ip once per run ()

Wrap get_local_ip in lru_cache
pull/49371/head
J. Nick Koston 2021-04-17 22:04:45 -10:00 committed by GitHub
parent 252bcabbea
commit b2c33c1373
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 1 deletions
homeassistant/util

View File

@ -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: