redis_connector/redis_connector.py
def _acquire_lock(self, message_id, lock_timeout=10):
        """Will lock the redis key for a max of 10 seconds,
        if the lock is free then it will process the message inmediatly, leaving it locked for the
        lock_timeout in all the cases, thus not allowing to process the messege to any other service.

        :param lock_timeout: Time in seconds the lock will be set before release
        :type lock_timeout: int

        :rtype: bool
        """
        expire_time = time.time() + (lock_timeout * 2 / 3)
        while time.time() < expire_time:
            if self._redis.setnx(message_id, expire_time):
                self._redis.expire(message_id, lock_timeout)
                return True

            elif not self._redis.ttl(message_id):
                self._redis.expire(message_id, lock_timeout)

            time.sleep(0.001)
        return False
Will lock the redis key for a max of 10 seconds,
        if the lock is free then it will process the message inmediatly, leaving it locked for the
        lock_timeout in all the cases, thus not allowing to process the messege to any other service.

        :param lock_timeout: Time in seconds the lock will be set before release
        :type lock_timeout: int

        :rtype: bool
        
Will lock the redis key for a max of 10 seconds,
if the lock is free then it will process the message inmediatly, leaving it locked for the
lock_timeout in all the cases, thus not allowing to process the messege to any other service.
Will lock the redis key for a max of 10 seconds if the lock is free then it will process the message inmediatly leaving it locked for the lock_timeout in all the cases thus not allowing to process the messege to any other service .
def _acquire_lock(self, message_id, lock_timeout=10):
        expire_time = time.time() + (lock_timeout * 2 / 3)
        while time.time() < expire_time:
            if self._redis.setnx(message_id, expire_time):
                self._redis.expire(message_id, lock_timeout)
                return True
            elif not self._redis.ttl(message_id):
                self._redis.expire(message_id, lock_timeout)
            time.sleep(0.001)
        return False
def _acquire_lock ( self , message_id , lock_timeout = 10 ) : expire_time = time . time ( ) + ( lock_timeout * 2 / 3 ) while time . time ( ) < expire_time : if self . _redis . setnx ( message_id , expire_time ) : self . _redis . expire ( message_id , lock_timeout ) return True elif not self . _redis . ttl ( message_id ) : self . _redis . expire ( message_id , lock_timeout ) time . sleep ( 0.001 ) return False
Will lock the redis key for a max of 10 seconds,
if the lock is free then it will process the message inmediatly, leaving it locked for the
lock_timeout in all the cases, thus not allowing to process the messege to any other service.
Will lock the redis key for a max of 10 seconds if the lock is free then it will process the message inmediatly leaving it locked for the lock_timeout in all the cases thus not allowing to process the messege to any other service .
"""Will lock the redis key for a max of 10 seconds,
        if the lock is free then it will process the message inmediatly, leaving it locked for the
        lock_timeout in all the cases, thus not allowing to process the messege to any other service.

        :param lock_timeout: Time in seconds the lock will be set before release
        :type lock_timeout: int

        :rtype: bool
        """
None
bool
self
message_id
lock_timeout
Time in seconds the lock will be set before release
Time in seconds the lock will be set before release