Skip to content

Commit

Permalink
Use Path.unlink instead of os.unlink to tolerate deleted lockfiles
Browse files Browse the repository at this point in the history
This should prevent issues like
#232 from appearing
  • Loading branch information
dcermak committed Oct 25, 2024
1 parent 1e19e12 commit 845f3d2
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion pytest_container/container.py
Original file line number Diff line number Diff line change
Expand Up @@ -1092,7 +1092,9 @@ def launch_container(self) -> None:
def release_lock() -> None:
_logger.debug("Releasing lock %s", lock.lock_file)
lock.release()
os.unlink(lock.lock_file)
# we're fine with another process/thread having deleted the
# lockfile, as long as the locking was thread safe
Path(lock.lock_file).unlink(missing_ok=True)

# Container preparation can fail, but then we would never release the
# lock as release_lock is not yet in self._stack. However, we do not
Expand Down

0 comments on commit 845f3d2

Please sign in to comment.