diff --git a/kraken/base_api/__init__.py b/kraken/base_api/__init__.py index e51d0f1e..f9a45819 100644 --- a/kraken/base_api/__init__.py +++ b/kraken/base_api/__init__.py @@ -661,7 +661,7 @@ async def __check_response_data( # pylint: disable=invalid-overridden-method raise Exception(f"{response.status} - {response.text}") - async def async_close(self: SpotAsyncClient) -> None: + async def close(self: SpotAsyncClient) -> None: """Closes the aiohttp session""" await self.__session.close() @@ -669,7 +669,7 @@ async def __aenter__(self: Self) -> Self: return self async def __aexit__(self: SpotAsyncClient, *args: object) -> None: - await self.async_close() + await self.close() class NFTClient(SpotClient): @@ -1142,7 +1142,7 @@ async def __check_response_data( # pylint: disable=invalid-overridden-method raise Exception(f"{response.status} - {response.text}") - async def async_close(self: FuturesAsyncClient) -> None: + async def close(self: FuturesAsyncClient) -> None: """Closes the aiohttp session""" await self.__session.close() @@ -1150,7 +1150,7 @@ async def __aenter__(self: Self) -> Self: return self async def __aexit__(self: FuturesAsyncClient, *args: object) -> None: - return await self.async_close() + return await self.close() __all__ = [ diff --git a/kraken/futures/ws_client.py b/kraken/futures/ws_client.py index de97a169..fdb922b4 100644 --- a/kraken/futures/ws_client.py +++ b/kraken/futures/ws_client.py @@ -153,10 +153,11 @@ async def start(self: FuturesWSClient) -> None: else: raise TimeoutError("Could not connect to the Kraken API!") - async def stop(self: FuturesWSClient) -> None: - """Method to stop the websocket connection.""" + async def close(self: FuturesWSClient) -> None: + """Method to close the websocket connection.""" if self._conn: await self._conn.stop() + await super().close() @property def key(self: FuturesWSClient) -> str: @@ -443,7 +444,7 @@ async def __aexit__( ) -> None: """Exit if used as context manager""" await super().__aexit__() - await self.stop() + await self.close() __all__ = ["FuturesWSClient"] diff --git a/kraken/spot/websocket/__init__.py b/kraken/spot/websocket/__init__.py index 27e19e5e..88884d79 100644 --- a/kraken/spot/websocket/__init__.py +++ b/kraken/spot/websocket/__init__.py @@ -137,12 +137,13 @@ async def start(self: SpotWSClientBase) -> None: else: raise TimeoutError("Could not connect to the Kraken API!") - async def stop(self: SpotWSClientBase) -> None: - """Method to stop the websocket connection.""" + async def close(self: SpotWSClientBase) -> None: + """Method to close the websocket connection.""" if self._pub_conn: await self._pub_conn.stop() if self._priv_conn: await self._priv_conn.stop() + await super().close() async def on_message( self: SpotWSClientBase, @@ -184,7 +185,7 @@ async def __aexit__( ) -> None: """Exit if used as context manager""" await super().__aexit__() - await self.stop() + await self.close() async def get_ws_token(self: SpotWSClientBase) -> dict: """ diff --git a/tests/futures/test_futures_base_api.py b/tests/futures/test_futures_base_api.py index ea38a007..1a84643b 100644 --- a/tests/futures/test_futures_base_api.py +++ b/tests/futures/test_futures_base_api.py @@ -118,7 +118,7 @@ async def check() -> None: dict, ) finally: - await client.async_close() + await client.close() run(check()) diff --git a/tests/futures/test_futures_websocket.py b/tests/futures/test_futures_websocket.py index 703a3dc1..ff4c62e3 100644 --- a/tests/futures/test_futures_websocket.py +++ b/tests/futures/test_futures_websocket.py @@ -34,7 +34,7 @@ async def instantiate_client() -> None: await client.start() await async_sleep(4) assert not client.is_auth - await client.stop() + await client.close() await async_sleep(2) asyncio.run(instantiate_client()) diff --git a/tests/spot/test_spot_base_api.py b/tests/spot/test_spot_base_api.py index 32f0b456..120575d3 100644 --- a/tests/spot/test_spot_base_api.py +++ b/tests/spot/test_spot_base_api.py @@ -98,7 +98,7 @@ async def check() -> None: ), ) finally: - await client.async_close() + await client.close() run(check()) @@ -225,7 +225,7 @@ async def check() -> None: ) sleep(2) finally: - await client.async_close() + await client.close() run(check()) diff --git a/tests/spot/test_spot_websocket.py b/tests/spot/test_spot_websocket.py index a66ebc01..8e15f80d 100644 --- a/tests/spot/test_spot_websocket.py +++ b/tests/spot/test_spot_websocket.py @@ -46,7 +46,7 @@ async def create_client() -> None: client = SpotWebsocketClientTestWrapper() await client.start() await async_sleep(5) - await client.stop() + await client.close() asyncio_run(create_client())