From: Zack Cerza Date: Wed, 2 Oct 2013 16:26:07 +0000 (-0500) Subject: Reuse connection objects. X-Git-Tag: 1.1.0~1839^2~14 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=cf68a3ac3a57a9cbef7b30523b96925a85fa6c4c;p=teuthology.git Reuse connection objects. Signed-off-by: Zack Cerza --- diff --git a/teuthology/report.py b/teuthology/report.py index 531778566e..f3d10a41ec 100755 --- a/teuthology/report.py +++ b/teuthology/report.py @@ -140,9 +140,8 @@ class ResultsPoster(object): jobs=len(jobs), )) if jobs: - h = httplib2.Http() run_json = json.dumps({'name': run_name}) - resp, content = h.request( + resp, content = self.http.request( "{base}/runs/".format(base=self.base_uri, name=run_name), 'POST', run_json, @@ -162,8 +161,7 @@ class ResultsPoster(object): def post_job(self, run_name, job_id): job_json = self.serializer.json_for_job(run_name, job_id) - h = httplib2.Http() - resp, content = h.request( + resp, content = self.http.request( "{base}/runs/{name}/".format(base=self.base_uri, name=run_name,), 'POST', job_json, @@ -175,7 +173,7 @@ class ResultsPoster(object): message = '' if message.endswith('already exists'): - resp, content = h.request( + resp, content = self.http.request( "{base}/runs/{name}/".format( base=self.base_uri, name=run_name,), @@ -208,6 +206,13 @@ class ResultsPoster(object): if os.path.exists(self.last_run_file): os.remove(self.last_run_file) + @property + def http(self): + if hasattr(self, '__http'): + return self.__http + self.__http = httplib2.Http() + return self.__http + def parse_args(): parser = argparse.ArgumentParser(