From fa675c711fa45c0007f3deded38579d70335ea7d Mon Sep 17 00:00:00 2001 From: Eero Vilpponen Date: Sat, 22 Aug 2020 06:00:27 +0000 Subject: [PATCH] Add retry for write --- homeassistant2influxdb.py | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/homeassistant2influxdb.py b/homeassistant2influxdb.py index 93b574a..ab0347a 100755 --- a/homeassistant2influxdb.py +++ b/homeassistant2influxdb.py @@ -169,11 +169,24 @@ def main(): batch_size_cur += 1 if batch_size_cur >= batch_size_max: - influx.write(batch_json) + while True: + try: + influx.write(batch_json) + except Exception as e: + print(e) + else: + break batch_json = [] batch_size_cur = 0 - influx.write(batch_json) + + while True: + try: + influx.write(batch_json) + except Exception as e: + print(e) + else: + break influx.close() # print statistics - ideally you have one friendly name per entity_id