Browse Source

lnbase: print exceptions from main_loop

dependabot/pip/contrib/deterministic-build/ecdsa-0.13.3
Janus 7 years ago
committed by ThomasV
parent
commit
e906e6e90a
  1. 28
      lib/lnbase.py

28
lib/lnbase.py

@ -4,6 +4,7 @@
Derived from https://gist.github.com/AdamISZ/046d05c156aaeb56cc897f85eecb3eb8 Derived from https://gist.github.com/AdamISZ/046d05c156aaeb56cc897f85eecb3eb8
""" """
import traceback
import itertools import itertools
import json import json
from collections import OrderedDict from collections import OrderedDict
@ -332,20 +333,23 @@ class Peer(PrintError):
# self.send_message(gen_msg('open_channel', funding_satoshis=funding_sat, push_msat=push_msat)) # self.send_message(gen_msg('open_channel', funding_satoshis=funding_sat, push_msat=push_msat))
async def main_loop(self): async def main_loop(self):
self.reader, self.writer = await asyncio.open_connection(self.host, self.port) try:
await self.handshake() self.reader, self.writer = await asyncio.open_connection(self.host, self.port)
# send init await self.handshake()
self.send_message(gen_msg("init", gflen=0, lflen=0)) # send init
# read init self.send_message(gen_msg("init", gflen=0, lflen=0))
msg = await self.read_message() # read init
self.process_message(msg)
# initialized
self.init_message_received_future.set_result(msg)
# loop
while True:
self.ping_if_required()
msg = await self.read_message() msg = await self.read_message()
self.process_message(msg) self.process_message(msg)
# initialized
self.init_message_received_future.set_result(msg)
# loop
while True:
self.ping_if_required()
msg = await self.read_message()
self.process_message(msg)
except:
traceback.print_exc()
# close socket # close socket
self.print_error('closing lnbase') self.print_error('closing lnbase')
self.writer.close() self.writer.close()

Loading…
Cancel
Save