diff options
| author | UltraQbik <no1skill@yandex.ru> | 2024-08-23 15:54:44 +0300 |
|---|---|---|
| committer | UltraQbik <no1skill@yandex.ru> | 2024-08-23 15:54:44 +0300 |
| commit | abb678c3582aec27329bd3cc77daf88472e30f90 (patch) | |
| tree | a3a3020307c055af758e0cf5fe8c1cb0d78eadc4 | |
| parent | 46a76eff285459d25f142d2ce2628425d4e69e94 (diff) | |
| download | httpy-abb678c3582aec27329bd3cc77daf88472e30f90.tar.gz httpy-abb678c3582aec27329bd3cc77daf88472e30f90.zip | |
Add timeout to prevent client thread from running forever
| -rw-r--r-- | main.py | 4 |
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 |