diff --git a/lbry/blob_exchange/server.py b/lbry/blob_exchange/server.py index 93f685233..a2ff8b698 100644 --- a/lbry/blob_exchange/server.py +++ b/lbry/blob_exchange/server.py @@ -107,12 +107,14 @@ class BlobServerProtocol(asyncio.Protocol): else: self.close() log.debug("stopped sending %s to %s:%i", blob_hash, peer_address, peer_port) + return except (OSError, ValueError, asyncio.TimeoutError) as err: if isinstance(err, asyncio.TimeoutError): log.debug("timed out sending blob %s to %s", blob_hash, peer_address) else: log.warning("could not read blob %s to send %s:%i", blob_hash, peer_address, peer_port) self.close() + return finally: self.transfer_finished.set() else: diff --git a/tests/unit/blob_exchange/test_transfer_blob.py b/tests/unit/blob_exchange/test_transfer_blob.py index 28a414996..f7c011e3b 100644 --- a/tests/unit/blob_exchange/test_transfer_blob.py +++ b/tests/unit/blob_exchange/test_transfer_blob.py @@ -219,6 +219,7 @@ class TestBlobExchange(BlobExchangeTestBase): server_protocol = BlobServerProtocol(self.loop, self.server_blob_manager, self.server.lbrycrd_address) transport = asyncio.Transport(extra={'peername': ('ip', 90)}) received_data = BytesIO() + transport.is_closing = lambda: received_data.closed transport.write = received_data.write server_protocol.connection_made(transport) blob_request = BlobRequest.make_request_for_blob_hash(blob_hash).serialize()