def main_loop(self, timeout=None):
        """
        Check if self.trigger_event is set. If it is, then run our function. If not, return early.
        :param timeout: How long to wait for a trigger event. Defaults to 0.
        :return:
        """
        if self.trigger_event.wait(timeout):
            try:
                self.func()
            except Exception as e:
                self.logger.warning("Got an exception running {func}: {e}".format(func=self.func, e=str(e)))
            finally:
                self.trigger_event.clear()