changeset 21:625064987b7c

Wrap gobject callbacks in exit_on_error to make more robust
author Daniel O'Connor <darius@dons.net.au>
date Thu, 09 Dec 2021 23:52:54 +1030
parents 8d48ca5294d3
children 02ba26698696
files eprodbus.py
diffstat 1 files changed, 3 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/eprodbus.py	Thu Dec 09 11:48:48 2021 +1030
+++ b/eprodbus.py	Thu Dec 09 23:52:54 2021 +1030
@@ -16,6 +16,7 @@
 
 sys.path.insert(1, os.path.join(os.path.dirname(__file__), 'velib_python'))
 from vedbus import VeDbusService
+from ve_utils import exit_on_error
 
 logger = logging.getLogger('eprodbus')
 logger.setLevel(logging.INFO)
@@ -47,8 +48,8 @@
         self.p = epro.Processor()
         self.s = s
         self.dbh = dbh
-        gobject.io_add_watch(s.fileno(), gobject.IO_IN, self.read_serial)
-        gobject.timeout_add(60000, self.log_epro)
+        gobject.io_add_watch(s.fileno(), gobject.IO_IN, lambda fd, userdata: exit_on_error(self.read_serial, fd, userdata))
+        gobject.timeout_add(60000, exit_on_error, self.log_epro)
 
     def read_serial(self, fd, userdata):
         try: