andymccurdy/redis-py — pull request #440 by Tin (2014-02-25 00:33:39+00:00)
Title: Add block_timeout to StrictRedis.lock

Add block_timeout to StrictRedis.lock. So when we lock a resource exlusively (timeout is long, or forever), we won't let others wait forever (stop blocking on a threshold).

Scenarios:
1. timeout=None, blocking_timeout=1: We want to lock a resource exclusively. So the lock won't expire. But we need a timeout threshold for other waiters. So those waiters may try their luck if the winner fail fast, but stop waiting for too long.
2. We need to make sure some critical resource only serve at interval of X. So we can set X as the lock's timeout. This will smooth the traffic by limit acquire interval, in that case if there are too much waiters, we will some of them timeout.