From 23b7ec3fb554254f80f7af14382b3693605b8728 Mon Sep 17 00:00:00 2001 From: Neil Booth Date: Sun, 19 Feb 2017 10:52:34 +0900 Subject: [PATCH] get_extra_info fix --- lib/jsonrpc.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/jsonrpc.py b/lib/jsonrpc.py index c06d3eb..489a528 100644 --- a/lib/jsonrpc.py +++ b/lib/jsonrpc.py @@ -760,9 +760,11 @@ class JSONSession(JSONSessionBase, asyncio.Protocol): def peer_info(self): '''Returns information about the peer.''' - if self.transport: + try: + # get_extra_info can throw even if self.transport is not None return self.transport.get_extra_info('peername') - return None + except Exception: + return None def abort(self): '''Cut the connection abruptly.''' @@ -776,7 +778,6 @@ class JSONSession(JSONSessionBase, asyncio.Protocol): def connection_lost(self, exc): '''Trigger timeouts of all pending requests.''' - self.transport = None self.timeout_session() def is_closing(self):