Open sc0rp10 opened 8 years ago
Sounds like a semaphore.
yes, sure, it's semaphore inside, but would be nice have two lock realizatons with same interface.
I would rather keep this library focused on its initial goal: a fast and robust lock for redis.
I don't have anything against implementing a semaphore but it seems to me that it would be better implemented in another library. Plus it's confusing, why would lock library implement a semaphore?
My little case: I need library, that can use Locks if holder=1 and use semaphore if holder=2-N: i don't like write code such as:
if holder == 1:
with redis_lock.Lock(r, key):
do_cricical_section()
else:
with redis_lock.Semaphore(r, key, holder):
do_cricical_section()
I prefer other approach:
with redis_lock.CommonLock(r, key, holder): # inside if holders > 1 using semaphore, otherwise - simple lock
do_cricical_section()
Your library is the best among its competitors, would be nice if inside her will be implemented other synchronization primitives.
Such as Consul offers: