summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorChristian Breunig <christian@breunig.cc>2026-11-08 19:53:30 +0100
committerChristian Breunig <christian@breunig.cc>2026-11-08 19:53:30 +0100
commitc66aaba4bc73b9b4fac943009212c27f567795d6 (patch)
tree0c11b9779187f44dba4a1b3a4288a6e568ce6310 /python
parent24531dad6605c06c1a5c9f7efb4cdabb82f8cc45 (diff)
downloadvyos-1x-c66aaba4bc73b9b4fac943009212c27f567795d6.tar.gz
vyos-1x-c66aaba4bc73b9b4fac943009212c27f567795d6.zip
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.
Diffstat (limited to 'python')
-rw-r--r--python/vyos/utils/wwan.py4
1 files changed, 3 insertions, 1 deletions
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