[devtool] randomise available ports search in http test
This lowers the chance of parallel tests to race for the same port.
--- a/devtools/httptest.py Wed Jul 03 14:48:34 2013 +0200
+++ b/devtools/httptest.py Wed Jul 03 14:52:10 2013 +0200
@@ -20,6 +20,7 @@
"""
__docformat__ = "restructuredtext en"
+import random
import threading
import socket
import httplib
@@ -46,6 +47,8 @@
.. see:: :func:`test.test_support.bind_port`
"""
+ ports_scan = list(ports_scan)
+ random.shuffle(ports_scan) # lower the chance of race condition
for port in ports_scan:
try:
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)