Commit 1a516b62 authored by Łukasz Nowak's avatar Łukasz Nowak

XXX testing/utils: Make ManagedHTTPServer threaded

It's used in context where many clients can connect in the same exact time,
like HAProxy balancer and real clients, which can result with seeing this
server as down.

XXX:
 * maybe it shall be selectable depending on the testing context...
parent 3ae06e91
......@@ -40,6 +40,7 @@ import json
from contextlib import closing
from six.moves import BaseHTTPServer
from six.moves import urllib_parse
from http.server import HTTPServer
from ..grid.utils import getPythonExecutableFromSoftwarePath
......@@ -142,7 +143,7 @@ class ManagedHTTPServer(ManagedResource):
"""
logger = self._cls.logger
class ErrorLoggingHTTPServer(BaseHTTPServer.HTTPServer):
class ErrorLoggingThreadedHTTPServer(ThreadingMixIn, BaseHTTPServer.HTTPServer):
def handle_error(self, request , client_addr):
# redirect errors to log
logger.info("Error processing request from %s", client_addr, exc_info=True)
......@@ -154,7 +155,7 @@ class ManagedHTTPServer(ManagedResource):
self.hostname,
self.port,
)
server = ErrorLoggingHTTPServer(
server = ErrorLoggingThreadedHTTPServer(
(self.hostname, self.port),
self.RequestHandler,
)
......
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