From abb678c3582aec27329bd3cc77daf88472e30f90 Mon Sep 17 00:00:00 2001 From: UltraQbik Date: Fri, 23 Aug 2024 15:54:44 +0300 Subject: Add timeout to prevent client thread from running forever --- main.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/main.py b/main.py index 4edd2ba..46740e9 100644 --- a/main.py +++ b/main.py @@ -107,6 +107,7 @@ class HTTPServer: :param client: client ssl socket """ + client.settimeout(5) while not self.stop_event.is_set(): try: # get client's request @@ -115,6 +116,9 @@ class HTTPServer: break print(request, end="\n\n") + except TimeoutError: + print("Client timeout") + break except OSError as e: print(e) break -- cgit 1.4.1