From b29cf737a70518775c17bfa6f2b226b962ea7d8d Mon Sep 17 00:00:00 2001 From: jkhsjdhjs Date: Tue, 26 Nov 2024 13:40:06 +0000 Subject: [PATCH] exit if a `TimeoutError` occurs --- bert.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/bert.py b/bert.py index c6e3f17..52111ef 100755 --- a/bert.py +++ b/bert.py @@ -140,10 +140,14 @@ def me(chan, msg): def getData(): - raw = irc.recv(4096) + try: + raw = irc.recv(4096) + except TimeoutError: + print("Connection timed out!") + sys.exit(0) if not raw: - print("Connection lost!") - sys.exit(0) + print("Connection lost!") + sys.exit(0) try: data = raw.decode("UTF-8") except: