redisco
redisco copied to clipboard
mutex lock timeout
using the current machine time to specify the mutex lock timeout is probably a bad idea since the internal time might drift slightly from machine to machine (they should all be using NTP, but I'd rather not rely on that).
https://github.com/kiddouk/redisco/blob/master/redisco/models/base.py#L763
Rather than using an absolute time, why not just set the key with a value of 1 and pipeline in the expire timeout of 1 second. Let redis determine when the key will expire by using it relative to the server time.
http://redis.io/commands/setex
pipeline these commands:
SET
Then you only ever have to see if the lock exists, and don't care about the value.