Bläddra i källkod

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

Shiv Tyagi 11 månader sedan
förälder
incheckning
ce201be66a
1 ändrade filer med 7 tillägg och 1 borttagningar
  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