(self, timeout=None)
Get an item from the queue or return None.  Do not block forever.
Get an item from the queue or return None.  Do not block forever.
Get an item from the queue or return None . Do not block forever .
def get(self, timeout=None):
        """Get an item from the queue or return None.  Do not block forever."""
        if self._item is not None:
            return self._item

        expire_at = int(time.time() + self._lock_timeout)

        with timeout_cm(timeout):  # won't block forever
            try:
                self._h_k = raw_client().evalsha(
                    self._SHAS['lq_get'],
                    len(self.SCRIPTS['lq_get']['keys']),
                    self._path, self._client_id, expire_at)
            except redis.exceptions.ResponseError as err:
                if str(err) not in ['queue empty', 'already locked']:
                    raise err

        if self._h_k:
            priority, insert_time, item = self._h_k.decode().split(':', 2)
            self._item = item
            self.LOCKS[self._h_k] = self._client_id
            return self._item
def get ( self , timeout = None ) : if self . _item is not None : return self . _item expire_at = int ( time . time ( ) + self . _lock_timeout ) with timeout_cm ( timeout ) : # won't block forever try : self . _h_k = raw_client ( ) . evalsha ( self . _SHAS [ 'lq_get' ] , len ( self . SCRIPTS [ 'lq_get' ] [ 'keys' ] ) , self . _path , self . _client_id , expire_at ) except redis . exceptions . ResponseError as err : if str ( err ) not in [ 'queue empty' , 'already locked' ] : raise err if self . _h_k : priority , insert_time , item = self . _h_k . decode ( ) . split ( ':' , 2 ) self . _item = item self . LOCKS [ self . _h_k ] = self . _client_id return self . _item