Skip to content

Commit 0819f69

Browse files
authored
Drops explicit cleanup on del (#88)
1 parent 7c97b28 commit 0819f69

File tree

3 files changed

+0
-30
lines changed

3 files changed

+0
-30
lines changed

keystone_client/http.py

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
"""
88

99
import abc
10-
import asyncio
1110
import re
1211
import uuid
1312
from typing import Optional, Union
@@ -115,9 +114,6 @@ def __enter__(self) -> 'HTTPClient':
115114
def __exit__(self, exc_type, exc_val, exc_tb) -> None:
116115
self.close()
117116

118-
def __del__(self) -> None:
119-
self.close()
120-
121117
def _client_factory(self, **kwargs) -> httpx.Client:
122118
"""Create a new HTTP client instance with the provided settings."""
123119

@@ -271,14 +267,6 @@ async def __aenter__(self) -> 'AsyncHTTPClient':
271267
async def __aexit__(self, exc_type, exc_val, exc_tb) -> None:
272268
await self.close()
273269

274-
def __del__(self) -> None:
275-
try:
276-
loop = asyncio.get_running_loop()
277-
loop.create_task(self._client.aclose())
278-
except RuntimeError:
279-
# No running loop; can't close asynchronously
280-
pass
281-
282270
def _client_factory(self, **kwargs) -> httpx.AsyncClient:
283271
"""Create a new HTTP client instance with the provided settings."""
284272

tests/unit_tests/test_http/test_AsyncHTTPClient.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -33,16 +33,6 @@ async def test_close_on_exit(self, mock_httpx_class: MagicMock) -> None:
3333

3434
mock_httpx_class.return_value.aclose.assert_called_once()
3535

36-
async def test_close_on_delete(self, mock_httpx_class: MagicMock) -> None:
37-
"""Verify any open sessions are closed when deleting an instance."""
38-
39-
mock_httpx_class.return_value.aclose = AsyncMock()
40-
41-
client = AsyncHTTPClient(base_url="https://example.com")
42-
del client
43-
44-
mock_httpx_class.return_value.aclose.assert_called_once()
45-
4636

4737
class SendRequestMethodAsync(IsolatedAsyncioTestCase):
4838
"""Test HTTP requests issued by the `send_requests` method."""

tests/unit_tests/test_http/test_HTTPClient.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,6 @@ def test_close_on_exit(self, mock_httpx_class: MagicMock) -> None:
2929

3030
mock_httpx_class.return_value.close.assert_called_once()
3131

32-
def test_close_on_delete(self, mock_httpx_class: MagicMock) -> None:
33-
"""Verify any open sessions are closed when deleting an instance."""
34-
35-
client = HTTPClient(base_url="https://example.com")
36-
del client
37-
38-
mock_httpx_class.return_value.close.assert_called_once()
39-
4032

4133
class SendRequestMethod(TestCase):
4234
"""Test HTTP requests issued by the `send_requests` method."""

0 commit comments

Comments
 (0)