Include retry algorithm in BasicLock.acquire, with accompanying tests
Add docstrings.

In the process, I discovered that it might be a good idea to use the new
'acquire' retry options in the with_lock implementation, so implement that as
well.
Use trap.