Browse Source

Avoid annoying exception on shutdown

master
Neil Booth 8 years ago
parent
commit
57dd4ece9c
  1. 8
      lib/jsonrpc.py
  2. 2
      server/protocol.py

8
lib/jsonrpc.py

@ -79,16 +79,12 @@ class JSONRPC(asyncio.Protocol, LoggedClass):
self.send_count = 0 self.send_count = 0
self.send_size = 0 self.send_size = 0
self.error_count = 0 self.error_count = 0
self.peer_info = None
def connection_made(self, transport): def connection_made(self, transport):
'''Handle an incoming client connection.''' '''Handle an incoming client connection.'''
self.transport = transport self.transport = transport
self.peer_info = transport.get_extra_info('peername')
def peer_info(self):
'''Return peer info.'''
if self.transport:
return self.transport.get_extra_info('peername')
return None
def connection_lost(self, exc): def connection_lost(self, exc):
'''Handle client disconnection.''' '''Handle client disconnection.'''

2
server/protocol.py

@ -224,7 +224,7 @@ class Session(JSONRPC):
self.manager.add_task(self, self.handle_json_request(request)) self.manager.add_task(self, self.handle_json_request(request))
def peername(self): def peername(self):
info = self.peer_info() info = self.peer_info
return 'unknown' if not info else '{}:{}'.format(info[0], info[1]) return 'unknown' if not info else '{}:{}'.format(info[0], info[1])
def tx_hash_from_param(self, param): def tx_hash_from_param(self, param):

Loading…
Cancel
Save