Require locks as long as expiry is not yet reached. 

This removes the randomness in waiting until trying to acquire a lock. the new code now retries to acquire a lock as long as the expiry time has not been reached yet and breaks when it is succeeded. 

A potential problem of the old code was:

Based on the randomness, the aggregated waiting time varied between ~ 10 to 20 seconds. This means a process might have failed unnecessarily after retrying the max amount of times during that period (before the expiry time was reached).