import subprocess
import sys
import collections
+import socket
+import random
from functools import reduce
+from contextlib import closing
import yaml
import six
else:
return_dic = return_dic[key]
return dic
+
+
+def get_free_port(ip):
+ with closing(socket.socket(socket.AF_INET, socket.SOCK_STREAM)) as s:
+ while True:
+ port = random.randint(5000, 10000)
+ if s.connect_ex((ip, port)) != 0:
+ return port