update
This commit is contained in:
@@ -4,7 +4,7 @@ import socket
|
||||
import threading
|
||||
from concurrent.futures import ThreadPoolExecutor
|
||||
|
||||
from httplib.exceptions import HTTPServerException, InternalServerError
|
||||
from httplib.exceptions import HTTPServerException, InternalServerError, HTTPServerCloseException
|
||||
from server.requesthandler import RequestHandler
|
||||
|
||||
THREAD_LIMIT = 128
|
||||
@@ -61,17 +61,25 @@ class Worker:
|
||||
self.shutdown()
|
||||
|
||||
def _handle_client(self, conn: socket.socket, addr):
|
||||
try:
|
||||
handler = RequestHandler(conn, self.host)
|
||||
handler.listen()
|
||||
except HTTPServerException as e:
|
||||
logging.debug("HTTP Exception:", exc_info=e)
|
||||
RequestHandler.send_error(conn, e.status_code, e.message)
|
||||
except socket.timeout:
|
||||
logging.debug("Socket for client %s timed out", addr)
|
||||
except Exception as e:
|
||||
logging.debug("Internal error", exc_info=e)
|
||||
RequestHandler.send_error(conn, InternalServerError.status_code, InternalServerError.message)
|
||||
|
||||
while True:
|
||||
try:
|
||||
handler = RequestHandler(conn, self.host)
|
||||
handler.listen()
|
||||
except HTTPServerCloseException as e:
|
||||
logging.debug("HTTP Exception:", exc_info=e)
|
||||
RequestHandler.send_error(conn, e.status_code, e.message)
|
||||
break
|
||||
except HTTPServerException as e:
|
||||
logging.debug("HTTP Exception:", exc_info=e)
|
||||
RequestHandler.send_error(conn, e.status_code, e.message)
|
||||
except socket.timeout:
|
||||
logging.debug("Socket for client %s timed out", addr)
|
||||
break
|
||||
except Exception as e:
|
||||
logging.debug("Internal error", exc_info=e)
|
||||
RequestHandler.send_error(conn, InternalServerError.status_code, InternalServerError.message)
|
||||
break
|
||||
|
||||
conn.shutdown(socket.SHUT_RDWR)
|
||||
conn.close()
|
||||
|
Reference in New Issue
Block a user