

def handle(self, key, value):
    '\n        Processes a vaild action info request\n\n        @param key: The key that matched the request\n        @param value: The value associated with the key\n        '
    elements = key.split(':')
    if (len(elements) != 4):
        self.logger.warn('Stop requests need a crawlid and appid')
        return
    spiderid = elements[1]
    appid = elements[2]
    crawlid = elements[3]
    uuid = value
    extras = self.get_log_dict('stop', appid, spiderid, uuid, crawlid)
    self.logger.info('Received stop request', extra=extras)
    redis_key = (spiderid + ':blacklist')
    value = '{appid}||{crawlid}'.format(appid=appid, crawlid=crawlid)
    self.redis_conn.sadd(redis_key, value)
    result = self._purge_crawl(spiderid, appid, crawlid)
    extras = {
        
    }
    extras['action'] = 'stop'
    extras['spiderid'] = spiderid
    extras['appid'] = appid
    extras['crawlid'] = crawlid
    extras['total_purged'] = result
    extras['uuid'] = uuid
    extras['server_time'] = int(self.get_current_time())
    if self._send_to_kafka(extras):
        timeout_key = 'timeout:{sid}:{aid}:{cid}'.format(sid=spiderid, aid=appid, cid=crawlid)
        self.redis_conn.delete(timeout_key)
        extras['success'] = True
        self.logger.info('Sent stop ack to kafka', extra=extras)
    else:
        extras['success'] = False
        self.logger.error('Failed to send stop ack to kafka', extra=extras)

dataset/ETHPy150Open istresearch/scrapy-cluster/redis-monitor/plugins/stop_monitor.py StopMonitor.handle/original