Explorar el Código

utils: wrap target method call in TaskRunner inside try-except

Shiv Tyagi hace 11 meses
padre
commit
ce201be66a
Se han modificado 1 ficheros con 7 adiciones y 1 borrados
  1. 7 1
      utils/taskrunner.py

+ 7 - 1
utils/taskrunner.py

@@ -46,7 +46,13 @@ class TaskRunner:
                         f"Now: {now}, Calling: {str(to_call)}, "
                         f"Runner id: {id(self)}"
                     )
-                    to_call()  # Call the method
+                    # Keep the thread alive even if an exception occurs
+                    # so that other tasks can keep running
+                    try:
+                        to_call()  # Call the method
+                    except Exception as e:
+                        logger.exception(e)
+
                     next_call_times[i] = now + period
 
             # Wait for the next call or stop event