Problem
lock(obj)
...
lock.release(obj)
will not release the lock properly if an exception occurs in between.
Proposed solution
We therefore should aim at
by implementing __enter__ and __exit__.
Alternative: I'm quite unsure what the owner/available mechanism brings here. If that was not needed, we could use a standard threading.Lock.