def handle_response(self,response): domain_set = {self._job.domain} if response.error: if self._job.retry_times != -1 and self._job.failure_times == self._job.retry_times: err = response.error info = "%d+%s+%s" % (err.code,str(err.message),self._job.request.url) logginghelper.error(logginghelper.LogicLog("None","Request","fail",info)) return (False,domain_set) self._job.execute(self.handle_response) self._job.failure_times += 1 return (False,None) return (True,domain_set)
def signal(self,domain): if not self._domain_task_queue.has_key(domain): return False if self.get_delay(domain): return False task_q = self._domain_task_queue[domain] if len(task_q) == 0: return False job = task_q.pop(0) cb_obj = self._cb_class(job) if not job.execute(cb_obj.handle_response): logginghelper.error(logginghelper.LogicLog("None","AddRequest","fail",job.request.url)) return False return True