mirror of
https://github.com/LBRYFoundation/lbry-sdk.git
synced 2025-09-01 17:55:13 +00:00
handle ConnectionError and ValueError in blob sendfile
This commit is contained in:
parent
34eb856d09
commit
2ed8ebff09
2 changed files with 4 additions and 3 deletions
|
@ -167,7 +167,7 @@ class AbstractBlob:
|
||||||
with self.reader_context() as handle:
|
with self.reader_context() as handle:
|
||||||
try:
|
try:
|
||||||
return await self.loop.sendfile(writer.transport, handle, count=self.get_length())
|
return await self.loop.sendfile(writer.transport, handle, count=self.get_length())
|
||||||
except (ConnectionResetError, BrokenPipeError, RuntimeError, OSError, AttributeError):
|
except (ConnectionError, BrokenPipeError, RuntimeError, OSError, AttributeError):
|
||||||
return -1
|
return -1
|
||||||
|
|
||||||
def decrypt(self, key: bytes, iv: bytes) -> bytes:
|
def decrypt(self, key: bytes, iv: bytes) -> bytes:
|
||||||
|
|
|
@ -105,8 +105,9 @@ class BlobServerProtocol(asyncio.Protocol):
|
||||||
self.blob_manager.connection_manager.sent_data(self.peer_address_and_port, sent)
|
self.blob_manager.connection_manager.sent_data(self.peer_address_and_port, sent)
|
||||||
log.info("sent %s (%i bytes) to %s:%i", blob_hash, sent, peer_address, peer_port)
|
log.info("sent %s (%i bytes) to %s:%i", blob_hash, sent, peer_address, peer_port)
|
||||||
else:
|
else:
|
||||||
|
self.close()
|
||||||
log.debug("stopped sending %s to %s:%i", blob_hash, peer_address, peer_port)
|
log.debug("stopped sending %s to %s:%i", blob_hash, peer_address, peer_port)
|
||||||
except (OSError, asyncio.TimeoutError) as err:
|
except (OSError, ValueError, asyncio.TimeoutError) as err:
|
||||||
if isinstance(err, asyncio.TimeoutError):
|
if isinstance(err, asyncio.TimeoutError):
|
||||||
log.debug("timed out sending blob %s to %s", blob_hash, peer_address)
|
log.debug("timed out sending blob %s to %s", blob_hash, peer_address)
|
||||||
else:
|
else:
|
||||||
|
@ -116,7 +117,7 @@ class BlobServerProtocol(asyncio.Protocol):
|
||||||
self.transfer_finished.set()
|
self.transfer_finished.set()
|
||||||
else:
|
else:
|
||||||
log.info("don't have %s to send %s:%i", blob.blob_hash[:8], peer_address, peer_port)
|
log.info("don't have %s to send %s:%i", blob.blob_hash[:8], peer_address, peer_port)
|
||||||
if responses:
|
if responses and not self.transport.is_closing():
|
||||||
self.send_response(responses)
|
self.send_response(responses)
|
||||||
|
|
||||||
def data_received(self, data):
|
def data_received(self, data):
|
||||||
|
|
Loading…
Add table
Reference in a new issue