'Deal one task'

def on_task(self, task, response):

    start_time = time.time()
    response = rebuild_response(response)
    try:
        assert ('taskid' in task), 'need    taskid    in    task'
        project = task['project']
        updatetime = task.get('project_updatetime', None)
        md5sum = task.get('project_md5sum', None)
        project_data = self.project_manager.get(project, updatetime, md5sum)
        assert project_data, 'no    such    project!'
        if project_data.get('exception'):
            ret = ProcessorResult(logs=(project_data.get('exception_log'),), exception=project_data['exception'])
        else:
            ret = project_data['instance'].run_task(project_data['module'], task, response)
    except Exception as e:
        logstr = traceback.format_exc()
        ret = ProcessorResult(logs=(logstr,), exception=e)
    process_time = (time.time() - start_time)
    if (not ret.extinfo.get('not_send_status', False)):
        if ret.exception:
            track_headers = dict(response.headers)
        else:
            track_headers = {}
            for name in ('etag', 'last-modified'):
                if (name not in response.headers):
                    continue
                track_headers[name] = response.headers[name]
        status_pack = {'taskid': task['taskid'], 'project': task['project'], 'url': task.get('url'), 'track': {'fetch': {'ok': response.isok(), 'redirect_url': (response.url if (response.url != response.orig_url) else None), 'time': response.time, 'error': response.error, 'status_code': response.status_code, 'encoding': getattr(response, '_encoding', None), 'headers': track_headers, 'content': (response.text[:500] if ret.exception else None)}, 'process': {'ok': (not ret.exception), 'time': process_time, 'follows': len(ret.follows), 'result': (None if (ret.result is None) else utils.text(ret.result)[:self.RESULT_RESULT_LIMIT]), 'logs': ret.logstr()[(- self.RESULT_LOGS_LIMIT):], 'exception': ret.exception}, 'save': ret.save}}
        if ('schedule' in task):
            status_pack['schedule'] = task['schedule']
        self.status_queue.put(utils.unicode_obj(status_pack))
    if ret.follows:
        for each in (ret.follows[x:(x + 1000)] for x in range(0, len(ret.follows), 1000)):
            self.newtask_queue.put([utils.unicode_obj(newtask) for newtask in each])
    for (project, msg, url) in ret.messages:
        try:
            self.on_task({'taskid': utils.md5string(url), 'project': project, 'url': url, 'process': {'callback': '_on_message'}}, {'status_code': 200, 'url': url, 'save': (task['project'], msg)})
        except Exception as e:
            logger.exception('Sending    message    error.')
            continue
    if ret.exception:
        logger_func = logger.error
    else:
        logger_func = logger.info
    logger_func(('process    %s:%s    %s    ->    [%d]    len:%d    ->    result:%.10r    fol:%d    msg:%d    err:%r' % (task['project'], task['taskid'], task.get('url'), response.status_code, len(response.content), ret.result, len(ret.follows), len(ret.messages), ret.exception)))
    return True
