Skip to content

Commit

Permalink
pylightning: Don't attempt to deserialize after every read
Browse files Browse the repository at this point in the history
We make use of the structure of the final read to decide when to deserialize.
  • Loading branch information
cdecker authored and rustyrussell committed Jul 16, 2018
1 parent 760b053 commit 356dcbb
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions contrib/pylightning/lightning/lightning.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ def _readobj(self, sock):
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"))
Expand Down

0 comments on commit 356dcbb

Please sign in to comment.