Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: closing keepAliveWebsocker fix #1531 #1533

Merged
merged 1 commit into from
Dec 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion binance/ws/streams.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def _get_account_socket(
url=self._get_stream_url(stream_url),
keepalive_type=path,
prefix=prefix,
exit_coro=self._exit_socket,
exit_coro=lambda p: self._exit_socket(conn_id),
is_binary=is_binary,
user_timeout=self._user_timeout,
https_proxy=self._client.https_proxy,
Expand Down
11 changes: 11 additions & 0 deletions tests/test_streams.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,21 @@ async def test_socket_stopped_on_aexit(clientAsync):
ts1 = bm.trade_socket("BNBBTC")
async with ts1:
pass
assert bm._conns == {}, "socket should be removed from _conn on exit"
ts2 = bm.trade_socket("BNBBTC")
assert ts2 is not ts1, "socket should be removed from _conn on exit"
await clientAsync.close_connection()

@pytest.mark.skipif(sys.version_info < (3, 8), reason="websockets_proxy Python 3.8+")
@pytest.mark.asyncio
async def test_socket_stopped_on_aexit_futures(futuresClientAsync):
bm = BinanceSocketManager(futuresClientAsync)
ts1 = bm.futures_user_socket()
async with ts1:
pass
assert bm._conns == {}, "socket should be removed from _conn on exit"
await futuresClientAsync.close_connection()


@pytest.mark.skipif(sys.version_info < (3, 8), reason="websockets_proxy Python 3.8+")
@pytest.mark.asyncio
Expand Down
Loading