diff --git a/ocaml/TaskServer.ml b/ocaml/TaskServer.ml index 8f6e6ddf..28a7d0a7 100644 --- a/ocaml/TaskServer.ml +++ b/ocaml/TaskServer.ml @@ -32,14 +32,19 @@ let zmq_context = let bind_socket ~socket_type ~socket ~address = - try - ZMQ.Socket.bind socket address - with - | Unix.Unix_error (_, message, f) -> - failwith @@ Printf.sprintf - "\n%s\nUnable to bind the %s socket :\n %s\n%s" - f socket_type address message - | other_exception -> raise other_exception + let rec loop = function + | 0 -> failwith @@ Printf.sprintf + "Unable to bind the %s socket : %s " + socket_type address + | -1 -> (); + | i -> + try + ZMQ.Socket.bind socket address; + loop (-1) + with + | Unix.Unix_error _ -> (Time.pause @@ Time.Span.of_float 1. ; loop (i-1) ) + | other_exception -> raise other_exception + in loop 10 let hostname = lazy ( diff --git a/ocaml/qp_run.ml b/ocaml/qp_run.ml index 2431139c..1d44f35f 100644 --- a/ocaml/qp_run.ml +++ b/ocaml/qp_run.ml @@ -32,12 +32,12 @@ let run ~master exe ezfio_file = let address = Printf.sprintf "tcp://%s:%d" (Lazy.force TaskServer.ip_address) (port_number+i) in - TaskServer.bind_socket "REP" dummy_socket address ; + ZMQ.Socket.bind dummy_socket address; ZMQ.Socket.unbind dummy_socket address; ); port_number with - | Failure _ -> try_new_port (port_number+100) + | Unix.Unix_error _ -> try_new_port (port_number+100) in let result = try_new_port 41279