self.recv() can return an empty array

This commit is contained in:
jesopo 2020-04-12 13:53:39 +01:00
parent 923809ab43
commit d571ad7ff9

View file

@ -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: