コード例 #1
0
    def add_to_blacklist(self, message):
        existing = redis_client.lrange('pending_blacklist:{}'.format(message.bounty_id), 0, -1)
        message_string = str(message)

        for key in existing:
            if key and key.decode('UTF-8') == message_string:
                logger.warning('Did not add {} to pending_blacklist, already '
                               'existed'.format(message.bounty_id))
                return

        redis_client.rpush('pending_blacklist:{}'.format(message.bounty_id), message_string)
        logger.warning('Added to {} to pending_blacklist'.format(message.bounty_id))
コード例 #2
0
 def resolve_blacklist(self):
     for key in redis_client.scan_iter('pending_blacklist:*'):
         logger.info(
             'Attempting to pop pending_blacklist queue {}'.format(key))
         try:
             retry = redis_client.lpop(key).decode('UTF-8')
             logger.warning('Retrying event: {}'.format(retry))
             self.handle_message(Message.from_string(retry))
         except Exception as e:
             # Don't re-raise - we just place it back in the list and try
             # again later
             logger.warning('Retrying event for {} failed with {}'.format(
                 key, e))
             redis_client.lpush(key, retry)
             retries = redis_client.lrange(key, 0, -1)
             print('length of retries')
             print(len(retries))