home · contact · privacy
Differentiate timeouts between server connection and Loop continuation.
authorChristian Heller <c.heller@plomlompom.de>
Fri, 30 May 2025 14:03:35 +0000 (16:03 +0200)
committerChristian Heller <c.heller@plomlompom.de>
Fri, 30 May 2025 14:03:35 +0000 (16:03 +0200)
ircplom.py

index 943d4e2c66aba83c1630768019829baf1b10148e..881a51c3e4a26d2ac410e81c45e633b1b0453430 100755 (executable)
@@ -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