Skip to content

Commit 66b94b6

Browse files
committed
Use an ephemeral port in bm_asyncio_websockets
1 parent b5d84d8 commit 66b94b6

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

‎pyperformance/data-files/benchmarks/bm_asyncio_websockets/run_benchmark.py‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,9 @@ async def main() -> None:
3535
global stop
3636
t0 = pyperf.perf_counter()
3737
stop = asyncio.Event()
38-
async with serve(handler, "", 8001, compression=None):
39-
async with connect("ws://localhost:8001", compression=None) as ws:
38+
async with serve(handler, "127.0.0.1", 0, compression=None) as server:
39+
port = server.sockets[0].getsockname()[1]
40+
async with connect(f"ws://127.0.0.1:{port}", compression=None) as ws:
4041
await asyncio.gather(*[send(ws) for _ in range(100)])
4142
await stop.wait()
4243
return pyperf.perf_counter() - t0

0 commit comments

Comments
 (0)