From 225f29abf416416c9b9dfe5ebec7067a7385f301 Mon Sep 17 00:00:00 2001 From: Christian Decker Date: Sat, 18 Mar 2017 16:06:52 +0100 Subject: [PATCH] pylightning: RPC returns a failure if the connection is lost --- contrib/pylightning/lightning/lightning.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/contrib/pylightning/lightning/lightning.py b/contrib/pylightning/lightning/lightning.py index 0550a281c..437ea3087 100644 --- a/contrib/pylightning/lightning/lightning.py +++ b/contrib/pylightning/lightning/lightning.py @@ -21,7 +21,10 @@ class UnixDomainSocketRpc(object): buff = b'' while True: try: - buff += sock.recv(1024) + b = sock.recv(1024) + buff += b + if len(b) == 0: + return {'error': 'Connection to RPC server lost.'} # Convert late to UTF-8 so glyphs split across recvs do not # impact us objs, _ = self.decoder.raw_decode(buff.decode("UTF-8"))