Skip to content

Commit

Permalink
fix(python-sdk): REST client should not close after stream request (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
evansims authored Feb 14, 2025
2 parents 4fa64a4 + cc3bb6e commit fe6c28c
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 14 deletions.
3 changes: 0 additions & 3 deletions config/clients/python/template/src/rest.py.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -397,9 +397,6 @@ class RESTClientObject:
# Release the response object (required!)
response.release()

# Release the connection back to the pool
await self.close()

async def request(
self,
method: str,
Expand Down
3 changes: 0 additions & 3 deletions config/clients/python/template/src/sync/rest.py.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -440,9 +440,6 @@ class RESTClientObject:
# Release the response object (required!)
response.release_conn()

# Release the connection back to the pool
self.close()

def request(
self,
method: str,
Expand Down
3 changes: 0 additions & 3 deletions config/clients/python/template/test/rest_test.py.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,6 @@ async def test_stream_happy_path():

client.handle_response_exception.assert_awaited_once()
mock_response.release.assert_called_once()
client.close.assert_awaited_once()


@pytest.mark.asyncio
Expand Down Expand Up @@ -353,7 +352,6 @@ async def test_stream_exception_in_chunks():
assert results == []
client.handle_response_exception.assert_awaited_once()
mock_response.release.assert_called_once()
client.close.assert_awaited_once()


@pytest.mark.asyncio
Expand Down Expand Up @@ -400,4 +398,3 @@ async def test_stream_partial_chunks():

client.handle_response_exception.assert_awaited_once()
mock_response.release.assert_called_once()
client.close.assert_awaited_once()
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,7 @@ def test_close():
client.pool_manager = mock_pool_manager

client.close()

mock_pool_manager.clear.assert_called_once()


Expand Down Expand Up @@ -322,7 +323,6 @@ def test_request_preload_content():
assert isinstance(resp, RESTResponse)
assert resp.status == 200
assert resp.data == b'{"some":"data"}'
mock_pool_manager.clear.assert_called_once()


def test_request_no_preload_content():
Expand Down Expand Up @@ -369,7 +369,6 @@ def test_request_no_preload_content():
# We expect the raw HTTPResponse
assert resp == mock_raw_response
assert resp.status == 200
mock_pool_manager.clear.assert_called_once()


def test_stream_happy_path():
Expand Down Expand Up @@ -420,7 +419,6 @@ def test_stream_happy_path():

assert results == [{"foo": "bar"}, {"hello": "world"}]
mock_pool_manager.request.assert_called_once()
mock_pool_manager.clear.assert_called_once()


def test_stream_partial_chunks():
Expand Down Expand Up @@ -472,7 +470,6 @@ def test_stream_partial_chunks():

assert results == [{"foo": "bar"}, {"hello": "world"}]
mock_pool_manager.request.assert_called_once()
mock_pool_manager.clear.assert_called_once()


def test_stream_exception_in_chunks():
Expand Down Expand Up @@ -523,4 +520,3 @@ def test_stream_exception_in_chunks():
# Exception is logged, we yield nothing
assert results == []
mock_pool_manager.request.assert_called_once()
mock_pool_manager.clear.assert_called_once()

0 comments on commit fe6c28c

Please sign in to comment.