diff --git a/src/horizon/listen.py b/src/horizon/listen.py index b2d37341..7b0e36f9 100644 --- a/src/horizon/listen.py +++ b/src/horizon/listen.py @@ -46,9 +46,14 @@ def read_all(self, sock, n): """ data = '' while n > 0: - buf = sock.recv(n) - n -= len(buf) - data += buf + chunk = sock.recv(n) + count = len(chunk) + + if count == 0: + break + + n -= count + data += chunk return data def check_if_parent_is_alive(self):