MCPcopy Create free account
hub / github.com/sammchardy/python-binance / test_ws_queue_overflow

Function test_ws_queue_overflow

tests/test_ws_api.py:201–224  ·  view source on GitHub ↗

WebSocket API should not overflow queue

(clientAsync)

Source from the content-addressed store, hash-verified

199@pytest.mark.skipif(sys.version_info < (3, 8), reason="websockets_proxy Python 3.8+")
200@pytest.mark.asyncio
201async def test_ws_queue_overflow(clientAsync):
202 """WebSocket API should not overflow queue"""
203 #
204 original_size = clientAsync.ws_api.max_queue_size
205 clientAsync.ws_api.max_queue_size = 1
206
207 try:
208 # Request multiple order books concurrently
209 symbols = ["BTCUSDT", "ETHUSDT", "BNBUSDT"]
210 tasks = [clientAsync.ws_get_order_book(symbol=symbol) for symbol in symbols]
211
212 # Execute all requests concurrently and wait for results
213 results = await asyncio.gather(*tasks, return_exceptions=True)
214
215 # Check that we got valid responses or expected overflow errors
216 valid_responses = [r for r in results if not isinstance(r, Exception)]
217 assert len(valid_responses) == len(symbols), "Should get at least one valid response"
218
219 for result in valid_responses:
220 assert_ob(result)
221
222 finally:
223 # Restore original queue size
224 clientAsync.ws_api.MAX_QUEUE_SIZE = original_size
225
226
227@pytest.mark.skipif(sys.version_info < (3, 8), reason="websockets_proxy Python 3.8+")

Callers

nothing calls this directly

Calls 2

assert_obFunction · 0.85
ws_get_order_bookMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…