python icon indicating copy to clipboard operation
python copied to clipboard

traceroute needs graceful recovery from error

Open roberthadow opened this issue 8 months ago • 1 comments

When traceroute fails, it fails catastrophically. It needs to be refactored to exit gracefully rather than hanging the system.

For testing pruposes, I have a bash script on my Ubuntu system with lines like this:

meshtastic --host 192.168.1.202 --traceroute '!b03dbb38'

When the command fails, it hangs in the terminal, typically something like this:

Exception in thread Thread-19:
Traceback (most recent call last):
  File "/home/rhadow/miniconda3/lib/python3.12/threading.py", line 1073, in _bootstrap_inner
    self.run()
  File "/home/rhadow/miniconda3/lib/python3.12/threading.py", line 1431, in run
    self.function(*self.args, **self.kwargs)
  File "/home/rhadow/miniconda3/lib/python3.12/site-packages/meshtastic/mesh_interface.py", line 1116, in callback
    self.sendHeartbeat()
  File "/home/rhadow/miniconda3/lib/python3.12/site-packages/meshtastic/mesh_interface.py", line 1105, in sendHeartbeat
    self._sendToRadio(p)
  File "/home/rhadow/miniconda3/lib/python3.12/site-packages/meshtastic/mesh_interface.py", line 1180, in _sendToRadio
    self._sendToRadioImpl(toRadio)
  File "/home/rhadow/miniconda3/lib/python3.12/site-packages/meshtastic/stream_interface.py", line 120, in _sendToRadioImpl
    self._writeBytes(header + b)
  File "/home/rhadow/miniconda3/lib/python3.12/site-packages/meshtastic/tcp_interface.py", line 79, in _writeBytes
    self.socket.send(b)

... It may generate a couple more threads, then just stop with

BrokenPipeError: [Errno 32] Broken pipe

Instead of returning control to the bash script, it just hangs.

It needs to detect the error, grafeully exit with notification, then allow the bash script to continue.

roberthadow avatar Apr 15 '25 14:04 roberthadow

This issue duplicates #765.

roberthadow avatar Apr 19 '25 13:04 roberthadow