(self)
background signal (not a thread) that keeps lock alive
background signal (not a thread) that keeps lock alive
background signal ( not a thread ) that keeps lock alive
def _extend_lock_in_background(self):
        """
        background signal (not a thread) that keeps lock alive
        """
        while True:
            try:
                s = time.time()
                threads = []
                results = []
                for path in list(self.LOCKS):
                    try:
                        client_id = self.LOCKS[path]
                    except KeyError:
                        continue  # race condition optimization
                    t = threading.Thread(
                        name="%s Extend %s %s" % (
                            self.__class__.__name__, path, client_id),
                        target=self._extend, args=(path, client_id, results))
                    t.daemon = True
                    t.start()
                    threads.append(t)
                for t in threads:
                    t.join()
                if len(threads) != len(results):
                    raise Exception("Failed to extend lock")
                for x in results:
                    if x[2] != 1:
                        raise Exception(
                            "Failed to extend lock for path: %s. redis_msg: %s"
                            % (x[0], x[2]))

                # adjust sleep time based on min expireat
                delta = time.time() - s
                sleep_time = \
                    self._lock_timeout - self._max_network_delay - delta
                assert self._lock_timeout > sleep_time > 0, (
                    'took too long to extend the locks.'
                    ' increase lock_timeout or reduce number of concurrent'
                    ' locks you have or improve network latency')
                time.sleep(sleep_time)
            except Exception as err:
                # kill parent process
                log.error(
                    'Redis Queue Backend asking Stolos to exit(1)'
                    ' because of err: %s' % err)
                os.kill(os.getpid(), BaseStolosRedis._SIGNAL)
                raise
def _extend_lock_in_background ( self ) : while True : try : s = time . time ( ) threads = [ ] results = [ ] for path in list ( self . LOCKS ) : try : client_id = self . LOCKS [ path ] except KeyError : continue # race condition optimization t = threading . Thread ( name = "%s Extend %s %s" % ( self . __class__ . __name__ , path , client_id ) , target = self . _extend , args = ( path , client_id , results ) ) t . daemon = True t . start ( ) threads . append ( t ) for t in threads : t . join ( ) if len ( threads ) != len ( results ) : raise Exception ( "Failed to extend lock" ) for x in results : if x [ 2 ] != 1 : raise Exception ( "Failed to extend lock for path: %s. redis_msg: %s" % ( x [ 0 ] , x [ 2 ] ) ) # adjust sleep time based on min expireat delta = time . time ( ) - s sleep_time = self . _lock_timeout - self . _max_network_delay - delta assert self . _lock_timeout > sleep_time > 0 , ( 'took too long to extend the locks.' ' increase lock_timeout or reduce number of concurrent' ' locks you have or improve network latency' ) time . sleep ( sleep_time ) except Exception as err : # kill parent process log . error ( 'Redis Queue Backend asking Stolos to exit(1)' ' because of err: %s' % err ) os . kill ( os . getpid ( ) , BaseStolosRedis . _SIGNAL ) raise