From 3b3dc41e867c7870978e5e54969498449d75cf01 Mon Sep 17 00:00:00 2001 From: Guillaume Desmottes <guillaume.desmottes@collabora.co.uk> Date: Fri, 9 Dec 2016 13:24:01 +0100 Subject: [PATCH] SysrootServer: set SO_REUSEADDR flag on the socket Should ensure that tests can still be run even if the previous one hasn't properly relased the port yet. Signed-off-by: Guillaume Desmottes <guillaume.desmottes@collabora.co.uk> Reviewed-by: Sjoerd Simons <sjoerd.simons@collabora.co.uk> Differential Revision: https://phabricator.apertis.org/D5220 --- tests/test_util.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tests/test_util.py b/tests/test_util.py index c07ccab..fbfe1f5 100644 --- a/tests/test_util.py +++ b/tests/test_util.py @@ -10,6 +10,7 @@ import http.server import os +import socket import subprocess import threading @@ -134,6 +135,10 @@ class SysrootServer(http.server.HTTPServer): os.chdir(os.path.join(os.path.dirname(os.path.realpath(__file__)), 'files')) super().__init__(("", 1234), SysrootHTTPRequestHandler) + def server_bind(self): + self.socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) + self.socket.bind(self.server_address) + def start(self): self.thread = threading.Thread(target=self.serve_forever) self.thread.daemon = True -- GitLab