Skip to content

Commit

Permalink
Catch BrokenPipeError on socket send
Browse files Browse the repository at this point in the history
If we lose connection while sending data to the server, a BrokenPipeError is sent. It was uncaught.
  • Loading branch information
hmpf authored Jan 31, 2024
1 parent eb0409f commit 3622dc4
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/zinolib/ritz.py
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,10 @@ def _request(self, command: bytes, recv_buffer=4096, **_):
delimiter = bytes(self.DELIMITER, 'ascii')
if not command.endswith(delimiter):
command += delimiter
self._sock.send(command)
try:
self._sock.send(command)
except BrokenPipeError as e:
raise NotConnectedError(f'Lost connection to server: {e}') from e
while data:
try:
data = self._sock.recv(recv_buffer)
Expand Down

0 comments on commit 3622dc4

Please sign in to comment.