| 17 | |
| 18 | |
| 19 | async def client(num): |
| 20 | # Space out connections to make them sequential. |
| 21 | await asyncio.sleep(num * INTERVAL) |
| 22 | |
| 23 | tracemalloc.start() |
| 24 | |
| 25 | async with connect( |
| 26 | "ws://localhost:8765", |
| 27 | extensions=[ |
| 28 | ClientPerMessageDeflateFactory( |
| 29 | server_max_window_bits=WB, |
| 30 | client_max_window_bits=WB, |
| 31 | compress_settings={"memLevel": ML}, |
| 32 | ) |
| 33 | ], |
| 34 | ) as ws: |
| 35 | await ws.send("hello") |
| 36 | await ws.recv() |
| 37 | |
| 38 | await ws.send(b"hello") |
| 39 | await ws.recv() |
| 40 | |
| 41 | MEM_SIZE.append(tracemalloc.get_traced_memory()[0]) |
| 42 | tracemalloc.stop() |
| 43 | |
| 44 | # Hold connection open until the end of the test. |
| 45 | await asyncio.sleep((CLIENTS + 1 - num) * INTERVAL) |
| 46 | |
| 47 | |
| 48 | async def clients(): |