Skip to content

Commit cb88472

Browse files
committed
Use an ephemeral port in bm_asyncio_websockets
1 parent 8a0713c commit cb88472

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 websockets.server.serve(handler, "", 8001):
39-
async with websockets.client.connect("ws://localhost:8001") as ws:
38+
async with websockets.server.serve(handler, "127.0.0.1", 0) as server:
39+
port = server.sockets[0].getsockname()[1]
40+
async with websockets.client.connect(f"ws://127.0.0.1:{port}") 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)