diff --git a/neon_utils/metrics_utils.py b/neon_utils/metrics_utils.py index 8e09b206..4fc53b8e 100644 --- a/neon_utils/metrics_utils.py +++ b/neon_utils/metrics_utils.py @@ -58,7 +58,10 @@ def __enter__(self): def __exit__(self, typ, val, traceback): self.stop() - self.report() + try: + self.report() + except Exception as e: + LOG.exception(e) def start(self): self.start_time = time() @@ -69,7 +72,9 @@ def stop(self): def report(self): if self._metric and self._report: - self._bus = self._bus or MessageBusClient() + if not self._bus: + self._bus = MessageBusClient() + self._bus.run_in_thread() message = dig_for_message() or Message("") message.context['timestamp'] = time() self._bus.emit(message.forward("neon.metric",