Use condition variables using 'with'

Instead of doing [acquire, try, finally, release]
just use the condition variable as a context manager
to achieve the same effect with less code and with
less verbosity.

Change-Id: I0a3bb80a932a3dc6623ba2378afa0341e9e06e5a