Address #189 ensuring socket locks are released
authorMichael <mike.ihde@gmail.com>
Wed, 31 Jan 2018 12:07:00 +0000 (07:07 -0500)
committerMichael <mike.ihde@gmail.com>
Wed, 31 Jan 2018 12:07:00 +0000 (07:07 -0500)
commitfb081b7cf6467fca173aa8c61c9024af2221ad60
tree117df074b9724da5f73ed1260bcb3b33930d858d
parent8996b7eaca8092a62fb9f2e659afa4533821900a
Address #189 ensuring socket locks are released

The code previous assume exception-free execution of critical blocks
between lock acquire() and lock release(); however, in Python exceptions
can be thrown in many situations which would then result in a dead-lock
of the entire program using pigpio.

This is resolved by using the acquire/try/finally/release pattern to
ensure that the lock is always released, even when an exception occurs.

Also addresses #186, but takes a slightly different approach by using
RLock to handle the nested lock requirement, which overall should be
safer because it handles additional situations that can cause a
deadlock.
pigpio.py