You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Pull request #12: EOA-3340 Update Python SDK to manage auto refresh of the connections
Merge in SDK/python_telesign from fix/EOA-3340/UpdatePythonSDKToManageAutoRefreshOfTheConnections1 to developer
* commit '9c9b77c6c277b2eadf740c1f4f129942a9bf8046':
solving english texts
deleting readme
EOA-3340 python sdk with auto refresh
Pull request #11: EOA-3340 Update Python SDK to manage auto refresh of the connections
Pull request #11: EOA-3340 Update Python SDK to manage auto refresh of the connections
Copy file name to clipboardExpand all lines: telesign/rest.py
+36-2Lines changed: 36 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -6,6 +6,7 @@
6
6
fromemail.utilsimportformatdate
7
7
fromhashlibimportsha256
8
8
fromplatformimportpython_version
9
+
importtime
9
10
10
11
importrequests
11
12
importjson
@@ -52,7 +53,8 @@ def __init__(self,
52
53
sdk_version_dependency=None,
53
54
proxies=None,
54
55
timeout=10,
55
-
auth_method=None):
56
+
auth_method=None,
57
+
pool_recycle=480):
56
58
"""
57
59
Telesign RestClient useful for making generic RESTful requests against our API.
58
60
@@ -62,13 +64,22 @@ def __init__(self,
62
64
:param proxies: (optional) Dictionary mapping protocol or protocol and hostname to the URL of the proxy.
63
65
:param timeout: (optional) How long to wait for the server to send data before giving up, as a float,
64
66
or as a (connect timeout, read timeout) tuple
67
+
:param pool_recycle: (optional) Time in seconds to recycle the HTTP session to avoid stale connections (default 480).
68
+
If a session is older than this value, it will be closed and a new session will be created automatically before each request.
69
+
This helps prevent errors due to HTTP keep-alive connections being closed by the server after inactivity.
70
+
71
+
HTTP Keep-Alive behavior:
72
+
TeleSign endpoints close idle HTTP keep-alive connections after 499 seconds. If you attempt to reuse a connection older than this, you may get a 'connection reset by peer' error.
73
+
By default, pool_recycle=480 ensures sessions are refreshed before this limit.
0 commit comments