Эх сурвалжийг харах

ircd/meetbot: Always flush buffers

Luther Blissett 3 жил өмнө
parent
commit
b1c6cdde85

+ 5 - 1
bin/ircd/script/meetbot.py

@@ -25,18 +25,22 @@ async def channel_listen(host, port, nick, chan):
         logging.debug("%s: Send CAP msg", chan)
         logging.debug("%s: Send CAP msg", chan)
         msg = "CAP REQ : no-history\r\n"
         msg = "CAP REQ : no-history\r\n"
         writer.write(msg.encode("utf-8"))
         writer.write(msg.encode("utf-8"))
+        await writer.drain()
 
 
         logging.debug("%s: Send NICK msg", chan)
         logging.debug("%s: Send NICK msg", chan)
         msg = f"NICK {nick}\r\n"
         msg = f"NICK {nick}\r\n"
         writer.write(msg.encode("utf-8"))
         writer.write(msg.encode("utf-8"))
+        await writer.drain()
 
 
         logging.debug("%s: Send CAP END msg", chan)
         logging.debug("%s: Send CAP END msg", chan)
         msg = "CAP END\r\n"
         msg = "CAP END\r\n"
         writer.write(msg.encode("utf-8"))
         writer.write(msg.encode("utf-8"))
+        await writer.drain()
 
 
         logging.debug("%s: Send JOIN msg", chan)
         logging.debug("%s: Send JOIN msg", chan)
         msg = f"JOIN {chan}\r\n"
         msg = f"JOIN {chan}\r\n"
         writer.write(msg.encode("utf-8"))
         writer.write(msg.encode("utf-8"))
+        await writer.drain()
 
 
         logging.info("%s: Listening to channel", chan)
         logging.info("%s: Listening to channel", chan)
         while True:
         while True:
@@ -167,7 +171,7 @@ async def channel_listen(host, port, nick, chan):
                     continue
                     continue
 
 
     except KeyboardInterrupt:
     except KeyboardInterrupt:
-        pass
+        return
     except ConnectionRefusedError:
     except ConnectionRefusedError:
         logging.warning("%s: Connection refused, trying again in 3s...", chan)
         logging.warning("%s: Connection refused, trying again in 3s...", chan)
         await asyncio.sleep(3)
         await asyncio.sleep(3)