I believe this is what it's referring to:
try:
lock.acquire()
finally:
lock.release()
If acquire()
raises an exception, release()
will be called, even though acquire()
didn't succeed. Calling release()
on a lock which isn't currently locked may raise another exception, i.e. an exception that is only indirectly related to the root of the problem.
The correct way to write the block would either be to use with
, or:
lock.acquire()
try:
...
finally:
lock.release()
You should always code to cater for exceptions, regardless of whether the documentation suggests that a call raises one or not. There's nothing to stop the behaviour changing in future.