With lock timeout

Code snippet used in next commit.