Commit 9eb67c81 authored by Julien Muchembled's avatar Julien Muchembled

tests: allocate ports outside default system range to minimize conflicts

git-svn-id: https://svn.erp5.org/repos/neo/trunk@2670 71dcc9de-d417-0410-9af5-da40c76e7ee4
parent aeb31eab
......@@ -70,8 +70,17 @@ class PortAllocator(object):
self.lock.acquire()
self.allocator_set[self] = None
self.socket_list.append(s)
s.bind((local_ip, 0))
while True:
# Do not let the system choose the port to avoid conflicts
# with other software. IOW, use a range different than:
# - /proc/sys/net/ipv4/ip_local_port_range on Linux
# - what IANA recommends (49152 to 65535)
try:
s.bind((local_ip, random.randint(16384, 32767)))
return s.getsockname()[1]
except socket.error, e:
if e.errno != errno.EADDRINUSE:
raise
def release(self):
for s in self.socket_list:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment