From 1f1c031882493c3f96e8b14b2b4915270110f54c Mon Sep 17 00:00:00 2001 From: manisha1997 Date: Fri, 17 Jan 2025 18:10:41 +0530 Subject: [PATCH 1/2] chore: update httpclient --- tests/unit/http/test_http_client.py | 7 +++++++ twilio/http/http_client.py | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/tests/unit/http/test_http_client.py b/tests/unit/http/test_http_client.py index 8484e57b1..6d3a191ec 100644 --- a/tests/unit/http/test_http_client.py +++ b/tests/unit/http/test_http_client.py @@ -292,6 +292,13 @@ def test_session_not_preserved(self): self.assertEqual(response_1.content, "response_1") self.assertEqual(response_2.content, "response_2") + def test_session_max_retries(self): + client = TwilioHttpClient(max_retries=10) + self.assertEqual(10, client.session.get_adapter("https://").max_retries.total) + client = TwilioHttpClient() + self.assertEqual(12, client.session.get_adapter("https://").poolmanager.connection_pool_kw['maxsize']) + + class MyVersion(Version): def __init__(self, domain): diff --git a/twilio/http/http_client.py b/twilio/http/http_client.py index e15be8635..2f2d36353 100644 --- a/twilio/http/http_client.py +++ b/twilio/http/http_client.py @@ -40,7 +40,7 @@ def __init__( self.session = Session() if pool_connections else None if self.session and max_retries is not None: self.session.mount("https://", HTTPAdapter(max_retries=max_retries)) - if self.session is not None: + elif self.session is not None: self.session.mount( "https://", HTTPAdapter(pool_maxsize=min(32, os.cpu_count() + 4)) ) From 9b04cdbf5a1a910581e66fcd2644d984fb34dc4b Mon Sep 17 00:00:00 2001 From: manisha1997 Date: Tue, 21 Jan 2025 19:03:40 +0530 Subject: [PATCH 2/2] chore: update httpclient --- tests/unit/http/test_http_client.py | 6 ------ 1 file changed, 6 deletions(-) diff --git a/tests/unit/http/test_http_client.py b/tests/unit/http/test_http_client.py index 6d3a191ec..cbd438251 100644 --- a/tests/unit/http/test_http_client.py +++ b/tests/unit/http/test_http_client.py @@ -292,12 +292,6 @@ def test_session_not_preserved(self): self.assertEqual(response_1.content, "response_1") self.assertEqual(response_2.content, "response_2") - def test_session_max_retries(self): - client = TwilioHttpClient(max_retries=10) - self.assertEqual(10, client.session.get_adapter("https://").max_retries.total) - client = TwilioHttpClient() - self.assertEqual(12, client.session.get_adapter("https://").poolmanager.connection_pool_kw['maxsize']) - class MyVersion(Version):