From a57c6627d90c95e3aacc95fe4df09d39b2fa5e34 Mon Sep 17 00:00:00 2001 From: Christian Heller Date: Fri, 30 May 2025 16:03:35 +0200 Subject: [PATCH] Differentiate timeouts between server connection and Loop continuation. --- ircplom.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/ircplom.py b/ircplom.py index 943d4e2..881a51c 100755 --- a/ircplom.py +++ b/ircplom.py @@ -17,7 +17,8 @@ PORT = 6667 USERNAME = 'foo' NICKNAME = 'bar' REALNAME = 'debug debugger' -TIMEOUT_FOR_QUIT = 1.0 +TIMEOUT_CONNECT = 5 +TIMEOUT_LOOP = 0.1 INPUT_PROMPT = ':' IRCSPEC_LINE_SEPARATOR = b'\r\n' @@ -104,7 +105,7 @@ class Terminal: while True: new_gotchs = [] if not n_gotchs_unprocessed: - while self._blessed.kbhit(TIMEOUT_FOR_QUIT): + while self._blessed.kbhit(TIMEOUT_LOOP): gotch = self._blessed.getch() self._blessed.ungetch(gotch) new_gotchs += [gotch] @@ -140,8 +141,9 @@ class Connection: ) -> Generator: 'Wrap socket and recv loop context.' with socket() as self._socket: - self._socket.settimeout(TIMEOUT_FOR_QUIT) + self._socket.settimeout(TIMEOUT_CONNECT) self._socket.connect(address) + self._socket.settimeout(TIMEOUT_LOOP) with SocketRecvLoop(q_to_main, self.read_lines()): yield self -- 2.30.2