Commit 6431be34 authored by Łukasz Nowak's avatar Łukasz Nowak

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