Skip to content

Commit 397ea0c

Browse files
authored
Close the lock file in pexes when we're doing (#236)
1 parent 2ab13c9 commit 397ea0c

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

tools/please_pex/pex/pex_main.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,12 @@ def explode_zip():
6262
def pex_lockfile(basepath, uniquedir):
6363
# Acquire the lockfile.
6464
lockfile_path = os.path.join(basepath, '.lock-%s' % uniquedir)
65-
lockfile = open(lockfile_path, "a+")
66-
# Block until we can acquire the lockfile.
67-
portalocker.lock(lockfile, portalocker.LOCK_EX)
68-
lockfile.seek(0)
69-
yield lockfile
70-
portalocker.lock(lockfile, portalocker.LOCK_UN)
65+
with open(lockfile_path, "a+") as lockfile:
66+
# Block until we can acquire the lockfile.
67+
portalocker.lock(lockfile, portalocker.LOCK_EX)
68+
lockfile.seek(0)
69+
yield lockfile
70+
portalocker.lock(lockfile, portalocker.LOCK_UN)
7171

7272
@contextlib.contextmanager
7373
def _explode_zip():

0 commit comments

Comments
 (0)