@@ -49,6 +49,7 @@ def __init__(self,
49
49
50
50
# lock for making sure we make one request at a time - requests module otherwise sometimes returns incomplete json objects
51
51
self ._lock = threading .Lock ()
52
+ self ._reqSession = requests .Session ()
52
53
self ._apiKey = apiKey
53
54
self ._extraParams = None
54
55
@@ -86,7 +87,7 @@ def checkVersion(self):
86
87
check what is the latest version of the python sdk and report in case there is a newer version
87
88
"""
88
89
try :
89
- respInfo = requests .get (self ._host + "/static/pythonSDKVersion.txt" )
90
+ respInfo = self . _reqSession .get (self ._host + "/static/pythonSDKVersion.txt" )
90
91
if respInfo .status_code != 200 or len (respInfo .text ) > 20 :
91
92
return
92
93
latestVersion = respInfo .text .strip ()
@@ -258,7 +259,7 @@ def jsonRequest(self, methodUrl, paramDict, customLogFName = None, allowUseOfArc
258
259
url = self ._host + methodUrl
259
260
260
261
# make the request
261
- respInfo = requests .post (url , json = paramDict )
262
+ respInfo = self . _reqSession .post (url , json = paramDict )
262
263
# remember the returned headers
263
264
self ._headers = respInfo .headers
264
265
# if we got some error codes print the error and repeat the request after a short time period
@@ -311,7 +312,7 @@ def jsonRequestAnalytics(self, methodUrl, paramDict):
311
312
tryCount += 1
312
313
try :
313
314
# make the request
314
- respInfo = requests .post (self ._hostAnalytics + methodUrl , json = paramDict )
315
+ respInfo = self . _reqSession .post (self ._hostAnalytics + methodUrl , json = paramDict )
315
316
# remember the returned headers
316
317
self ._headers = respInfo .headers
317
318
# if we got some error codes print the error and repeat the request after a short time period
0 commit comments