From 5b620eedb50ba2f2d8a55e5120e5450b6cab50c7 Mon Sep 17 00:00:00 2001 From: CamDavidsonPilon Date: Fri, 21 Jul 2023 13:36:39 -0400 Subject: [PATCH] try this way to ensure msg are always sent --- pioreactor/cli/pio.py | 7 ++++++- requirements/requirements.txt | 2 +- setup.py | 2 +- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/pioreactor/cli/pio.py b/pioreactor/cli/pio.py index 7c512ea4..d6c81cc2 100644 --- a/pioreactor/cli/pio.py +++ b/pioreactor/cli/pio.py @@ -140,7 +140,12 @@ def log(message: str, level: str, name: str, local_only: bool): to_mqtt=not local_only, ) getattr(logger, level)(message) - sleep(0.5) # wait to make sure msg gets to mqtt + + # flush and close handlers + for handler in logger.handlers: + handler.flush() + handler.close() + except Exception: # don't let a logging error bring down a script... pass diff --git a/requirements/requirements.txt b/requirements/requirements.txt index 39e39b75..bb0fe39b 100644 --- a/requirements/requirements.txt +++ b/requirements/requirements.txt @@ -1,4 +1,4 @@ -click==8.1.3 +click==8.1.6 paho-mqtt==1.6.1 psutil==5.9.5 sh==1.14.2 diff --git a/setup.py b/setup.py index 05a42f12..06b6c24f 100644 --- a/setup.py +++ b/setup.py @@ -8,7 +8,7 @@ CORE_REQUIREMENTS = [ - "click==8.1.3", + "click==8.1.6", "paho-mqtt==1.6.1", "psutil==5.9.5", "sh==1.14.3",