'Setup redis connection and idle signal.
This should be called after the spider has set its crawler object.'

def setup_redis(self, crawler=None):

    if (self.server is not None):
        return
    if (crawler is None):
        crawler = getattr(self, 'crawler', None)
    if (crawler is None):
        raise ValueError('crawler    is    required')
    settings = crawler.settings
    if (self.redis_key is None):
        self.redis_key = settings.get('REDIS_START_URLS_KEY', defaults.START_URLS_KEY)
    self.redis_key = (self.redis_key % {'name': self.name})
    if (not self.redis_key.strip()):
        raise ValueError('redis_key    must    not    be    empty')
    if (self.redis_batch_size is None):
        self.redis_batch_size = settings.getint('REDIS_START_URLS_BATCH_SIZE', settings.getint('CONCURRENT_REQUESTS'))
    try:
        self.redis_batch_size = int(self.redis_batch_size)
    except (TypeError, ValueError):
        raise ValueError('redis_batch_size    must    be    an    integer')
    if (self.redis_encoding is None):
        self.redis_encoding = settings.get('REDIS_ENCODING', defaults.REDIS_ENCODING)
    self.logger.info("Reading    start    URLs    from    redis    key    '%(redis_key)s'    (batch    size:    %(redis_batch_size)s,    encoding:    %(redis_encoding)s", self.__dict__)
    self.server = connection.from_settings(crawler.settings)
    crawler.signals.connect(self.spider_idle, signal=signals.spider_idle)
