fix for broken socket timeout
This commit is contained in:
+14
-5
@@ -39,15 +39,14 @@ TODO: actually put normal comments in
|
|||||||
TODO: INPROG: add typing to all code, new code will feature it by default.
|
TODO: INPROG: add typing to all code, new code will feature it by default.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
import sys
|
||||||
|
import threading
|
||||||
import os
|
import os
|
||||||
import mimetypes
|
import mimetypes
|
||||||
import threading
|
import threading
|
||||||
import ssl
|
import ssl
|
||||||
import socket
|
import socket
|
||||||
|
|
||||||
# import re
|
|
||||||
import signal
|
import signal
|
||||||
import sys
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if not os.getcwd() in sys.path:
|
if not os.getcwd() in sys.path:
|
||||||
@@ -505,6 +504,7 @@ class WebServer:
|
|||||||
self.http_socket.listen(5)
|
self.http_socket.listen(5)
|
||||||
print(f"HTTP server listening on port {self.http_port}...")
|
print(f"HTTP server listening on port {self.http_port}...")
|
||||||
while self.running:
|
while self.running:
|
||||||
|
print(f"State of self.running: {self.running}")
|
||||||
try:
|
try:
|
||||||
conn, addr = self.http_socket.accept()
|
conn, addr = self.http_socket.accept()
|
||||||
if self.file_handler.read_config("threading") is True:
|
if self.file_handler.read_config("threading") is True:
|
||||||
@@ -515,7 +515,11 @@ class WebServer:
|
|||||||
).start()
|
).start()
|
||||||
else:
|
else:
|
||||||
self.handle_connection(conn, addr)
|
self.handle_connection(conn, addr)
|
||||||
except OSError:
|
except OSError as e:
|
||||||
|
if f"{e}" == "timed out":
|
||||||
|
continue
|
||||||
|
else:
|
||||||
|
print(f"OSError! {e}")
|
||||||
break
|
break
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
if not "timeout" in f"{e}":
|
if not "timeout" in f"{e}":
|
||||||
@@ -525,6 +529,7 @@ class WebServer:
|
|||||||
self.https_socket.listen(5)
|
self.https_socket.listen(5)
|
||||||
print(f"HTTPS server listening on port {self.https_port}...")
|
print(f"HTTPS server listening on port {self.https_port}...")
|
||||||
while self.running:
|
while self.running:
|
||||||
|
print(f"State of self.running: {self.running}")
|
||||||
try:
|
try:
|
||||||
conn, addr = self.https_socket.accept()
|
conn, addr = self.https_socket.accept()
|
||||||
if self.file_handler.read_config("threading") is True:
|
if self.file_handler.read_config("threading") is True:
|
||||||
@@ -535,7 +540,11 @@ class WebServer:
|
|||||||
).start()
|
).start()
|
||||||
else:
|
else:
|
||||||
self.handle_connection(conn, addr)
|
self.handle_connection(conn, addr)
|
||||||
except OSError:
|
except OSError as e:
|
||||||
|
if f"{e}" == "timed out":
|
||||||
|
continue
|
||||||
|
else:
|
||||||
|
print(f"OSError! {e}")
|
||||||
break
|
break
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
if not "timeout" in f"{e}":
|
if not "timeout" in f"{e}":
|
||||||
|
|||||||
Reference in New Issue
Block a user