mirror of
https://github.com/home-assistant/core.git
synced 2025-07-25 06:07:17 +00:00
Only fetch the local ip once per run (#49336)
Wrap get_local_ip in lru_cache
This commit is contained in:
parent
252bcabbea
commit
b2c33c1373
@ -4,7 +4,7 @@ from __future__ import annotations
|
|||||||
import asyncio
|
import asyncio
|
||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
import enum
|
import enum
|
||||||
from functools import wraps
|
from functools import lru_cache, wraps
|
||||||
import random
|
import random
|
||||||
import re
|
import re
|
||||||
import socket
|
import socket
|
||||||
@ -129,6 +129,7 @@ def ensure_unique_string(
|
|||||||
|
|
||||||
|
|
||||||
# Taken from: http://stackoverflow.com/a/11735897
|
# Taken from: http://stackoverflow.com/a/11735897
|
||||||
|
@lru_cache(maxsize=None)
|
||||||
def get_local_ip() -> str:
|
def get_local_ip() -> str:
|
||||||
"""Try to determine the local IP address of the machine."""
|
"""Try to determine the local IP address of the machine."""
|
||||||
try:
|
try:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user