We are running lots of jenkins projects in parallel. We are using python, and we have chosen to manage the virtual environments with pyenv. Unfortunately, pyenv has a well-known race condition. To work around the problem, I would like to implement locking at the process level. What I want to do is:
lock some resource (a file?)
do my pyenv stuff
unlock the resource
My scripts are written in bash. How can I implement resource locking / unlocking in bash?
I would consider using symlinks instead of regular files - because, symlink creation is an atomic operation. So, we could do this: