Merge pull request #2487 from lbryio/fix-connection-reset

handle error if range request transport is reset
This commit is contained in:
Jack Robison 2019-10-08 16:20:07 -04:00 committed by GitHub
commit 44b27bbfc8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -289,8 +289,8 @@ class ManagedStream:
await response.prepare(request) await response.prepare(request)
self.streaming_responses.append((request, response)) self.streaming_responses.append((request, response))
self.streaming.set() self.streaming.set()
try:
wrote = 0 wrote = 0
try:
async for blob_info, decrypted in self._aiter_read_stream(skip_blobs, connection_id=self.STREAMING_ID): async for blob_info, decrypted in self._aiter_read_stream(skip_blobs, connection_id=self.STREAMING_ID):
if not wrote: if not wrote:
decrypted = decrypted[first_blob_start_offset:] decrypted = decrypted[first_blob_start_offset:]
@ -308,6 +308,9 @@ class ManagedStream:
if response._eof_sent: if response._eof_sent:
break break
return response return response
except ConnectionResetError:
log.warning("connection was reset after sending browser %i blob bytes", wrote)
raise asyncio.CancelledError("range request transport was reset")
finally: finally:
response.force_close() response.force_close()
if (request, response) in self.streaming_responses: if (request, response) in self.streaming_responses: