Skip to content

Commit 88498c5

Browse files
committed
Added session so that subsequent calls use the same connection
1 parent 8c0abdc commit 88498c5

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

alchemyapi.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ class AlchemyAPI:
130130
#The base URL for all endpoints
131131
BASE_URL = 'http://access.alchemyapi.com/calls'
132132

133+
s = requests.Session()
133134

134135
def __init__(self):
135136
"""
@@ -762,7 +763,7 @@ def __analyze(self, endpoint, params, post_data=bytearray()):
762763
post_url = AlchemyAPI.BASE_URL + endpoint + '?' + urlencode(params).encode('utf-8');
763764

764765
try:
765-
return requests.post(url=post_url, data=post_data).json()
766+
return self.s.post(url=post_url, data=post_data).json()
766767
except Exception as e:
767768
print(e)
768769
return { 'status':'ERROR', 'statusInfo':'network-error' }

0 commit comments

Comments
 (0)