diff --git a/teuthology/report.py b/teuthology/report.py index 6c662819f79..a97a1854365 100644 --- a/teuthology/report.py +++ b/teuthology/report.py @@ -132,7 +132,8 @@ class ResultsSerializer(object): class ResultsReporter(object): last_run_file = 'last_successful_run' - def __init__(self, archive_base, base_uri=None, save=False, refresh=False): + def __init__(self, archive_base, base_uri=None, save=False, refresh=False, + timeout=20): self.archive_base = archive_base self.base_uri = base_uri or config.results_server if self.base_uri: @@ -140,6 +141,7 @@ class ResultsReporter(object): self.serializer = ResultsSerializer(archive_base) self.save_last_run = save self.refresh = refresh + self.timeout = timeout def _do_request(self, uri, method, json_): """ @@ -189,16 +191,7 @@ class ResultsReporter(object): runs = all_runs[next_index:] else: runs = all_runs - num_runs = len(runs) - num_jobs = 0 - log.info("Posting %s runs", num_runs) - for run in runs: - job_count = self.report_run(run) - num_jobs += job_count - if self.save_last_run: - self.last_run = run - del self.last_run - log.info("Total: %s jobs in %s runs", num_jobs, num_runs) + return self.report_runs(runs) def report_runs(self, run_names): """ @@ -206,9 +199,15 @@ class ResultsReporter(object): :param run_names: The names of the runs. """ + num_runs = len(run_names) num_jobs = 0 - for run_name in run_names: - num_jobs += self.report_run(run_name) + log.info("Posting %s runs", num_runs) + for run in run_names: + job_count = self.report_run(run) + num_jobs += job_count + if self.save_last_run: + self.last_run = run + del self.last_run log.info("Total: %s jobs in %s runs", num_jobs, len(run_names)) def create_run(self, run_name): @@ -305,7 +304,7 @@ class ResultsReporter(object): def http(self): if hasattr(self, '__http'): return self.__http - self.__http = httplib2.Http() + self.__http = httplib2.Http(timeout=self.timeout) return self.__http