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