From b36cf3e36c2a4b1875951c99d0cd6740dd0a1ea5 Mon Sep 17 00:00:00 2001 From: Victor Shyba Date: Fri, 1 Feb 2019 20:07:41 -0300 Subject: [PATCH] remove closing peers from active connections --- lbrynet/blob_exchange/downloader.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/lbrynet/blob_exchange/downloader.py b/lbrynet/blob_exchange/downloader.py index 2cd0ed219..af54876a2 100644 --- a/lbrynet/blob_exchange/downloader.py +++ b/lbrynet/blob_exchange/downloader.py @@ -33,10 +33,14 @@ class BlobDownloader: async def _request_blob(): if blob.get_is_verified(): return - success, keep_connection = await request_blob( - self.loop, blob, peer.address, peer.tcp_port, self.config.peer_connect_timeout, - self.config.blob_download_timeout - ) + try: + success, keep_connection = await request_blob( + self.loop, blob, peer.address, peer.tcp_port, self.config.peer_connect_timeout, + self.config.blob_download_timeout + ) + finally: + if peer in self.active_connections: + self.active_connections.pop(peer) if not keep_connection and peer not in self.ignored: self.ignored.add(peer) log.debug("drop peer %s:%i", peer.address, peer.tcp_port)