[Neo-report] r2670 jm - /trunk/neo/tests/functional/__init__.py
nobody at svn.erp5.org
nobody at svn.erp5.org
Thu Mar 17 20:39:52 CET 2011
Author: jm
Date: Thu Mar 17 20:39:52 2011
New Revision: 2670
Log:
tests: allocate ports outside default system range to minimize conflicts
Modified:
trunk/neo/tests/functional/__init__.py
Modified: trunk/neo/tests/functional/__init__.py
==============================================================================
--- trunk/neo/tests/functional/__init__.py [iso-8859-1] (original)
+++ trunk/neo/tests/functional/__init__.py [iso-8859-1] Thu Mar 17 20:39:52 2011
@@ -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))
- return s.getsockname()[1]
+ 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:
More information about the Neo-report
mailing list