Running many of these experiments can result in a lot of time waiting for the file locks to be released. This PR implements the it's easier to ask for forgiveness than for permission pattern and iteratively tries to read a file instead of locking it first. Only if that fails it tries to lock the file. Also, constructing the surrogate is now done inside the file lock to avoid constructing the same surrogate multiple times. I'm not 100% sure if loading the file within the lock is still necessary, but it definitively won't hurt.
Running many of these experiments can result in a lot of time waiting for the file locks to be released. This PR implements the it's easier to ask for forgiveness than for permission pattern and iteratively tries to read a file instead of locking it first. Only if that fails it tries to lock the file. Also, constructing the surrogate is now done inside the file lock to avoid constructing the same surrogate multiple times. I'm not 100% sure if loading the file within the lock is still necessary, but it definitively won't hurt.