fix for broken socket timeout
This commit is contained in:
+16
-7
@@ -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,8 +515,12 @@ class WebServer:
|
||||
).start()
|
||||
else:
|
||||
self.handle_connection(conn, addr)
|
||||
except OSError:
|
||||
break
|
||||
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}":
|
||||
print(f"HTTP error: {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,8 +540,12 @@ class WebServer:
|
||||
).start()
|
||||
else:
|
||||
self.handle_connection(conn, addr)
|
||||
except OSError:
|
||||
break
|
||||
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}":
|
||||
print(f"HTTPS error: {e}")
|
||||
|
||||
Reference in New Issue
Block a user