add option to retry acquiring a lock

also add option to control sleep time while waiting for lock

Paired with: @yanowitz and @nchainani