This commit is contained in:
2021-03-25 12:16:40 +01:00
parent 7639383782
commit edfdc94747
5 changed files with 42 additions and 11 deletions

View File

@@ -1,10 +1,10 @@
import logging
import multiprocessing as mp
import socket
import threading
from concurrent.futures import ThreadPoolExecutor
from logging import Logger
import socket
from httplib.exceptions import HTTPServerException, InternalServerError
from server.RequestHandler import RequestHandler
THREAD_LIMIT = 128
@@ -23,10 +23,8 @@ def worker(address, name, logging_level, queue: mp.Queue, stop_event: mp.Event):
class Worker:
host: str
name: str
logger: Logger
queue: mp.Queue
executor: ThreadPoolExecutor
stop_event: mp.Event
@@ -68,8 +66,11 @@ class Worker:
handler = RequestHandler(conn, self.host)
handler.listen()
except Exception:
logging.debug("Internal error")
except HTTPServerException as e:
RequestHandler.send_error(conn, e.status_code, e.message)
except Exception as e:
RequestHandler.send_error(conn, InternalServerError.status_code, InternalServerError.message)
logging.debug("Internal error", exc_info=e)
conn.shutdown(socket.SHUT_RDWR)
conn.close()