Add forking support.

This commit is contained in:
Darko Poljak 2016-10-30 20:25:32 +01:00
parent 297367390f
commit 8c985fe2cb

View file

@ -24,6 +24,7 @@ import logging
import re import re
import socket import socket
import http.server import http.server
import socketserver
from http.server import BaseHTTPRequestHandler, HTTPServer from http.server import BaseHTTPRequestHandler, HTTPServer
@ -49,10 +50,6 @@ class Trigger():
# can only be set once # can only be set once
multiprocessing.set_start_method('forkserver') multiprocessing.set_start_method('forkserver')
# Create pool suitable for passing objects
def __init_pool(self):
pass
def run_httpd(self): def run_httpd(self):
server_address = ('', self.http_port) server_address = ('', self.http_port)
@ -78,7 +75,6 @@ class Trigger():
class TriggerHttp(BaseHTTPRequestHandler): class TriggerHttp(BaseHTTPRequestHandler):
def do_GET(self): def do_GET(self):
# FIXME: dispatch to pool instead of single process
host = self.client_address[0] host = self.client_address[0]
code = 200 code = 200
mode = None mode = None
@ -124,7 +120,7 @@ class TriggerHttp(BaseHTTPRequestHandler):
parallel=False) parallel=False)
class HTTPServerV6(http.server.HTTPServer): class HTTPServerV6(socketserver.ForkingMixIn, http.server.HTTPServer):
""" """
Server that listens both to IPv4 and IPv6 requests. Server that listens both to IPv4 and IPv6 requests.
""" """