From d571ad7ff98c963658fb7fbf6caf0b11d0198297 Mon Sep 17 00:00:00 2001 From: jesopo Date: Sun, 12 Apr 2020 13:53:39 +0100 Subject: [PATCH] self.recv() can return an empty array --- ircrobots/server.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/ircrobots/server.py b/ircrobots/server.py index b8785b5..586f93a 100644 --- a/ircrobots/server.py +++ b/ircrobots/server.py @@ -106,11 +106,13 @@ class Server(IServer): if self._read_queue: both = self._read_queue.popleft() else: - data = await self._reader.read(1024) - lines = self.recv(data) - - self._read_queue.extend(lines[1:]) - both = lines[0] + data = await self._reader.read(1024) + while True: + lines = self.recv(data) + if lines: + self._read_queue.extend(lines[1:]) + both = lines[0] + break line, emits = both for emit in emits: