diff --git a/analysisstore/client/asutils.py b/analysisstore/client/asutils.py index 052e4e0..ceebd1e 100644 --- a/analysisstore/client/asutils.py +++ b/analysisstore/client/asutils.py @@ -5,8 +5,11 @@ import six +session = requests.Session() + + def get_document(url, doc_type, as_json, contents): - r = requests.get(url, params=ujson.dumps(contents)) + r = session.get(url, params=ujson.dumps(contents)) r.raise_for_status() content = ujson.loads(r.text) if as_json: @@ -18,7 +21,7 @@ def get_document(url, doc_type, as_json, contents): def post_document(url, contents): try: - r = requests.post(url, data=ujson.dumps(contents)) + r = session.post(url, data=ujson.dumps(contents)) except ConnectionError: raise ConnectionError('No AnalysisStore server found') r.raise_for_status() # this is for catching server side issue.