Skip to content

Commit

Permalink
Merge pull request #68 from JunAishima/use-session
Browse files Browse the repository at this point in the history
Use session
  • Loading branch information
JunAishima authored Oct 9, 2024
2 parents 857c379 + f6eeccc commit b45f6f3
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions amostra/client/amutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
import ujson


session = requests.Session()


def doc_or_uid_to_uid(doc_or_uid):
"""Given Document or uid return the uid
Expand Down Expand Up @@ -38,7 +41,7 @@ def _get(url, params):
Results of the query
"""
r = requests.get(url, ujson.dumps(params))
r = session.get(url, params=ujson.dumps(params))
r.raise_for_status()
return ujson.loads(r.text)

Expand All @@ -54,7 +57,7 @@ def _post(url, data):
Entries to be inserted to database
"""
r = requests.post(url,
r = session.post(url,
data=ujson.dumps(data))
r.raise_for_status()
return r.json()
Expand Down Expand Up @@ -83,6 +86,6 @@ def _put(url, query, update):
"""
update_cont = {'query': query, 'update': update}
r = requests.put(url,
r = session.put(url,
data=ujson.dumps(update_cont))
r.raise_for_status()

0 comments on commit b45f6f3

Please sign in to comment.