fix for broken socket timeout

This commit is contained in:
Bill Gates
2026-08-10 13:33:19 +02:00
parent 3276224943
commit 4a93ffa20c
+14 -5
View File
@@ -39,15 +39,14 @@ TODO: actually put normal comments in
TODO: INPROG: add typing to all code, new code will feature it by default.
"""
import sys
import threading
import os
import mimetypes
import threading
import ssl
import socket
# import re
import signal
import sys
try:
if not os.getcwd() in sys.path:
@@ -505,6 +504,7 @@ class WebServer:
self.http_socket.listen(5)
print(f"HTTP server listening on port {self.http_port}...")
while self.running:
print(f"State of self.running: {self.running}")
try:
conn, addr = self.http_socket.accept()
if self.file_handler.read_config("threading") is True:
@@ -515,7 +515,11 @@ class WebServer:
).start()
else:
self.handle_connection(conn, addr)
except OSError:
except OSError as e:
if f"{e}" == "timed out":
continue
else:
print(f"OSError! {e}")
break
except Exception as e:
if not "timeout" in f"{e}":
@@ -525,6 +529,7 @@ class WebServer:
self.https_socket.listen(5)
print(f"HTTPS server listening on port {self.https_port}...")
while self.running:
print(f"State of self.running: {self.running}")
try:
conn, addr = self.https_socket.accept()
if self.file_handler.read_config("threading") is True:
@@ -535,7 +540,11 @@ class WebServer:
).start()
else:
self.handle_connection(conn, addr)
except OSError:
except OSError as e:
if f"{e}" == "timed out":
continue
else:
print(f"OSError! {e}")
break
except Exception as e:
if not "timeout" in f"{e}":