On 8/8/2014 2:35 PM, Neil D. Cerutti wrote:
Here's another attempt at context managing:
@contextlib.contextmanager
def release_if_acquired(lock, blocking=True, timeout=-1):
acquired = lock.acquire(blocking, timeout)
if acquired:
yield acquired
lock.release()
else:
yield acquired
I should not have used a temporary.
@contextlib.contextmanager
def release_if_acquired(lock, blocking=True, timeout=-1):
if lock.acquire(blocking, timeout)
yield True
lock.release()
else:
yield False
--
Neil Cerutti
--
https://mail.python.org/mailman/listinfo/python-list