ros_comm
ros_comm copied to clipboard
Add exception hook and log them on logerr
properly log exception within threads on logerr
behavior before change:
process[test_node-1]: started with pid [21234]
Exception in thread Thread-4:
Traceback (most recent call last):
File "/usr/lib/python3.8/threading.py", line 932, in _bootstrap_inner
self.run()
File "/home/sahin/catkin_ws/install/lib/test_package/test.py", line 14, in run
raise Exception('in thread')
Exception: in thread
[test_node-1] process has finished cleanly
behavior after change:
process[test_node-1]: started with pid [21059]
[/test_node ERROR 1642419799.922205]: Traceback (most recent call last):
File "/usr/lib/python3.8/threading.py", line 932, in _bootstrap_inner
self.run()
File "/home/sahin/catkin_ws/install/lib/test_package/test.py", line 14, in run
raise Exception('in thread')
Exception: in thread
[test_node-1] process has finished cleanly
This change makes it easier for log analytics to group together tracebacks for prioritizing bugfixes
Modified the change a bit to also include the exception hook from sys.excepthook https://docs.python.org/3/library/sys.html#sys.excepthook