From c7292aa4b67ca6ab9e454a0fa4dd6b974ca8666c Mon Sep 17 00:00:00 2001 From: "Seth R. Johnson" Date: Tue, 6 Sep 2022 12:50:59 -0400 Subject: Fix spack locking on some NFS systems (#32426) Co-authored-by: Todd Gamblin --- lib/spack/llnl/util/lock.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/spack/llnl/util/lock.py b/lib/spack/llnl/util/lock.py index 0682ce059a..6dfba50abb 100644 --- a/lib/spack/llnl/util/lock.py +++ b/lib/spack/llnl/util/lock.py @@ -386,8 +386,12 @@ class Lock(object): try: os.makedirs(parent) except OSError as e: - # makedirs can fail when diretory already exists. - if not (e.errno == errno.EEXIST and os.path.isdir(parent) or e.errno == errno.EISDIR): + # os.makedirs can fail in a number of ways when the directory already exists. + # With EISDIR, we know it exists, and others like EEXIST, EACCES, and EROFS + # are fine if we ensure that the directory exists. + # Python 3 allows an exist_ok parameter and ignores any OSError as long as + # the directory exists. + if not (e.errno == errno.EISDIR or os.path.isdir(parent)): raise return parent -- cgit v1.2.3-60-g2f50