refactor: Stop tracing service gracefully

This commit is contained in:
Gabriel Luiz Freitas Almeida 2024-06-23 22:34:05 -03:00
commit 152f0254c0

View file

@ -66,9 +66,12 @@ class TracingService(Service):
try:
self.running = False
await self.flush()
# check the qeue is empty
if not self.logs_queue.empty():
await self.logs_queue.join()
self.worker_task.cancel()
if self.worker_task:
await self.worker_task
self.worker_task = None
except Exception as e:
logger.error(f"Error stopping tracing service: {e}")