Skip to content

Commit

Permalink
Catch broken pipes and OS errors in websocket thread (Fixes #177)
Browse files Browse the repository at this point in the history
  • Loading branch information
miguelgrinberg committed Oct 21, 2020
1 parent 6ac8772 commit 0dde7d7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion engineio/asyncio_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -635,7 +635,8 @@ async def _write_loop(self):
await self.ws.send_str(pkt.encode(
always_bytes=False))
self.queue.task_done()
except aiohttp.client_exceptions.ServerDisconnectedError:
except (aiohttp.client_exceptions.ServerDisconnectedError,
BrokenPipeError, OSError):
self.logger.info(
'Write loop: WebSocket connection was closed, '
'aborting')
Expand Down
3 changes: 2 additions & 1 deletion engineio/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -741,7 +741,8 @@ def _write_loop(self):
else:
self.ws.send(encoded_packet)
self.queue.task_done()
except websocket.WebSocketConnectionClosedException:
except (websocket.WebSocketConnectionClosedException,
BrokenPipeError, OSError):
self.logger.warning(
'WebSocket connection was closed, aborting')
break
Expand Down

0 comments on commit 0dde7d7

Please sign in to comment.