about summary refs log tree commit diff
path: root/main.py
diff options
context:
space:
mode:
authorUltraQbik <no1skill@yandex.ru>2024-08-23 15:54:44 +0300
committerUltraQbik <no1skill@yandex.ru>2024-08-23 15:54:44 +0300
commitabb678c3582aec27329bd3cc77daf88472e30f90 (patch)
treea3a3020307c055af758e0cf5fe8c1cb0d78eadc4 /main.py
parent46a76eff285459d25f142d2ce2628425d4e69e94 (diff)
downloadhttpy-abb678c3582aec27329bd3cc77daf88472e30f90.tar.gz
httpy-abb678c3582aec27329bd3cc77daf88472e30f90.zip
Add timeout to prevent client thread from running forever
Diffstat (limited to 'main.py')
-rw-r--r--main.py4
1 files changed, 4 insertions, 0 deletions
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