Skip to content

Commit

Permalink
fix: handle transport exceptions from local connection
Browse files Browse the repository at this point in the history
  • Loading branch information
pjknkda committed Feb 9, 2022
1 parent 03e8b64 commit 092713c
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions rabbit_tunnel/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,11 @@ async def _reader_puller() -> None:
raise RuntimeError('Reader is not initialized')

while True:
data = await reader.read(_READ_BUFFER)
try:
data = await reader.read(_READ_BUFFER)
except (RuntimeError, ConnectionResetError, BrokenPipeError):
break

if not data:
break

Expand All @@ -82,7 +86,7 @@ async def _reader_puller() -> None:
'data': data,
}))
except WsConnectionClosedError:
return
break
finally:
await _close('local-connection-closed')

Expand Down Expand Up @@ -126,7 +130,7 @@ async def _reader_puller() -> None:
try:
writer.write(msg['data'])
await writer.drain()
except ConnectionResetError:
except (RuntimeError, ConnectionResetError, BrokenPipeError):
await _close('local-connection-closed')
break

Expand Down

0 comments on commit 092713c

Please sign in to comment.