Use threading in integrated webserver
This commit is contained in:
parent
2c45b1998c
commit
ff3b31fed6
@ -30,6 +30,7 @@ import os
|
||||
import pprint
|
||||
import base64
|
||||
import socket
|
||||
import socketserver
|
||||
import ssl
|
||||
import wsgiref.simple_server
|
||||
import re
|
||||
@ -92,6 +93,14 @@ class HTTPSServer(HTTPServer):
|
||||
self.server_activate()
|
||||
|
||||
|
||||
class ThreadedHTTPServer(socketserver.ThreadingMixIn, HTTPServer):
|
||||
pass
|
||||
|
||||
|
||||
class ThreadedHTTPSServer(socketserver.ThreadingMixIn, HTTPSServer):
|
||||
pass
|
||||
|
||||
|
||||
class RequestHandler(wsgiref.simple_server.WSGIRequestHandler):
|
||||
"""HTTP requests handler."""
|
||||
def log_message(self, *args, **kwargs):
|
||||
|
@ -33,7 +33,8 @@ import ssl
|
||||
from wsgiref.simple_server import make_server
|
||||
|
||||
from . import (
|
||||
Application, config, HTTPServer, HTTPSServer, log, RequestHandler, VERSION)
|
||||
Application, config, ThreadedHTTPServer, ThreadedHTTPSServer, log,
|
||||
RequestHandler, VERSION)
|
||||
|
||||
|
||||
# This is a script, many branches and variables
|
||||
@ -152,7 +153,7 @@ def run():
|
||||
# Create collection servers
|
||||
servers = {}
|
||||
if configuration.getboolean("server", "ssl"):
|
||||
server_class = HTTPSServer
|
||||
server_class = ThreadedHTTPSServer
|
||||
server_class.certificate = configuration.get("server", "certificate")
|
||||
server_class.key = configuration.get("server", "key")
|
||||
server_class.cyphers = configuration.get("server", "cyphers")
|
||||
@ -168,7 +169,7 @@ def run():
|
||||
"Error while reading SSL %s %r: %s" % (
|
||||
name, filename, exception))
|
||||
else:
|
||||
server_class = HTTPServer
|
||||
server_class = ThreadedHTTPServer
|
||||
|
||||
if not configuration.getboolean("server", "dns_lookup"):
|
||||
RequestHandler.address_string = lambda self: self.client_address[0]
|
||||
|
Loading…
Reference in New Issue
Block a user