summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/spack/spack/database.py14
1 files changed, 13 insertions, 1 deletions
diff --git a/lib/spack/spack/database.py b/lib/spack/spack/database.py
index 404288ff83..907b73c5db 100644
--- a/lib/spack/spack/database.py
+++ b/lib/spack/spack/database.py
@@ -50,6 +50,7 @@ except ImportError:
pass
import llnl.util.filesystem as fs
+import llnl.util.lang
import llnl.util.tty as tty
import spack.deptypes as dt
@@ -121,6 +122,17 @@ DEFAULT_INSTALL_RECORD_FIELDS = (
)
+@llnl.util.lang.memoized
+def _getfqdn():
+ """Memoized version of `getfqdn()`.
+
+ If we call `getfqdn()` too many times, DNS can be very slow. We only need to call it
+ one time per process, so we cache it here.
+
+ """
+ return socket.getfqdn()
+
+
def reader(version: vn.StandardVersion) -> Type["spack.spec.SpecfileReaderBase"]:
reader_cls = {
vn.Version("5"): spack.spec.SpecfileV1,
@@ -1084,7 +1096,7 @@ class Database:
self._state_is_inconsistent = True
return
- temp_file = self._index_path + (".%s.%s.temp" % (socket.getfqdn(), os.getpid()))
+ temp_file = self._index_path + (".%s.%s.temp" % (_getfqdn(), os.getpid()))
# Write a temporary database file them move it into place
try: