def acquire(self, block=True):
        """Acquire lock. Blocks until acquired if `block` is `True`, otherwise returns `False` if the lock could not be acquired."""
        while True:
            # Try to set the lock
            if self.redis.set(self.name, self.value, px=self.timeout, nx=True):
                # It's ours until the timeout now
                return True
            # Lock is taken
            if not block:
                return False
            # If blocking, try again in a bit
            time.sleep(self.sleep)
def acquire ( self , block = True ) : while True : if self . redis . set ( self . name , self . value , px = self . timeout , nx = True ) : return True if not block : return False time . sleep ( self . sleep )
Acquire lock. Blocks until acquired if `block` is `True`, otherwise returns `False` if the lock could not be acquired.