From 356dcbba975c8c5caede473fbb187fd2705a6689 Mon Sep 17 00:00:00 2001 From: Christian Decker Date: Fri, 13 Jul 2018 14:15:37 +0200 Subject: [PATCH] pylightning: Don't attempt to deserialize after every read We make use of the structure of the final read to decide when to deserialize. --- contrib/pylightning/lightning/lightning.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/contrib/pylightning/lightning/lightning.py b/contrib/pylightning/lightning/lightning.py index 477975234..bb3c5a8ca 100644 --- a/contrib/pylightning/lightning/lightning.py +++ b/contrib/pylightning/lightning/lightning.py @@ -29,6 +29,10 @@ class UnixDomainSocketRpc(object): buff += b if len(b) == 0: return {'error': 'Connection to RPC server lost.'} + + if buff[-3:] != b' }\n': + continue + # Convert late to UTF-8 so glyphs split across recvs do not # impact us objs, _ = self.decoder.raw_decode(buff.decode("UTF-8"))