From c66aaba4bc73b9b4fac943009212c27f567795d6 Mon Sep 17 00:00:00 2001 From: Christian Breunig Date: Sun, 8 Nov 2026 19:53:30 +0100 Subject: wwan: T9388: import tempfile only when recording bearer state The WWAN helpers imported tempfile at module level, which loads shutil, random and the bz2/lzma/zlib modules. As these helpers are imported by the configuration dictionary helpers, every process importing those paid about 2 ms for it, although only writing the bearer state needs it. --- python/vyos/utils/wwan.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'python') diff --git a/python/vyos/utils/wwan.py b/python/vyos/utils/wwan.py index 949fbbeba..421c67694 100644 --- a/python/vyos/utils/wwan.py +++ b/python/vyos/utils/wwan.py @@ -24,7 +24,6 @@ would have done. """ import os -import tempfile from time import sleep @@ -219,6 +218,9 @@ def _set_bearer_state(ifname: str, family: str, key: str, value) -> None: except FileNotFoundError: pass return None + # Imported here as it pulls in shutil, random and the compression modules + import tempfile + os.makedirs(bearer_state_dir, exist_ok=True) # The FRR renderer reads this while it is being written, so a reader # must never see a truncated or partial value -- cgit v1.2.3