Skip to content

Commit

Permalink
network: Log all network errors
Browse files Browse the repository at this point in the history
  • Loading branch information
tchx84 committed Feb 23, 2024
1 parent c8e1a08 commit b3bd912
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
5 changes: 4 additions & 1 deletion src/gameeky/client/network/tcp.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,10 @@ def send(self, data: str) -> None:
if self._cancellable.is_cancelled() is True:
return

self._data_output_stream.put_string(data + DEFAULT_SEPARATOR)
try:
self._data_output_stream.put_string(data + DEFAULT_SEPARATOR)
except Exception as e:
logger.error(e)

def shutdown(self) -> None:
self._cancellable.cancel()
Expand Down
8 changes: 6 additions & 2 deletions src/gameeky/server/network/tcp.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,17 @@ def do_send(self, data: str) -> None:
if self._server.cancellable.is_cancelled():
return

self._data_output_stream.put_string(data + DEFAULT_SEPARATOR)
try:
self._data_output_stream.put_string(data + DEFAULT_SEPARATOR)
except Exception as e:
logger.error(e)

def run(self) -> None:
while not self._server.cancellable.is_cancelled():
try:
data, _ = self._data_input_stream.read_line(None)
except:
except Exception as e:
logger.error(e)
break

if not data:
Expand Down

0 comments on commit b3bd912

Please sign in to comment.