From c97d9d7b5a61f8133e9ec83daebbbf663f93d9cd Mon Sep 17 00:00:00 2001 From: JamesWrigley Date: Mon, 27 May 2024 15:29:16 +0200 Subject: [PATCH] Use an arbitrary available port during precompilation This avoids conflict with other processes using the same port. --- src/ZMQ.jl | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/ZMQ.jl b/src/ZMQ.jl index aad7a99..71d3097 100644 --- a/src/ZMQ.jl +++ b/src/ZMQ.jl @@ -58,8 +58,12 @@ import PrecompileTools: @compile_workload s2=Socket(REQ) - ZMQ.bind(s1, "tcp://*:5555") - ZMQ.connect(s2, "tcp://localhost:5555") + ZMQ.bind(s1, "tcp://localhost:*") + # Strip the trailing null-terminator + last_endpoint = s1.last_endpoint[1:end - 1] + # Parse the port from the endpoint + port = parse(Int, split(last_endpoint, ":")[end]) + ZMQ.connect(s2, "tcp://localhost:$(port)") msg = Message("test request")