Current use of manual get_lock, release_lock calls is not exception safe, the with statement can be used to ensure exception safety

Issue #9 resolved
Prof Garth Wells created an issue

From Martin Sandve Alnæs :

This code will cause problems (e.g. deadlocks) in instant today:

lock = get_lock(...)
do_something() # raises exception
release_lock(lock) # not released

The with statement was introduced to python for precisely this reason, so we should make locking in instant work something like this:

with get_lock(...) as lock:
    do_something() # raises exception
# python inserts a call to lock.__exit__() or something here, allowing exception safe lock release