fix: retry InfluxDB writes and notify on failure
Co-authored-by: aider (gemini/gemini-3.1-pro-preview) <aider@aider.chat>
This commit is contained in:
@@ -149,11 +149,16 @@ class Sensor():
|
|||||||
'fields': data,
|
'fields': data,
|
||||||
}
|
}
|
||||||
|
|
||||||
try:
|
for attempt in range(3):
|
||||||
sensors_client.write_points([point])
|
try:
|
||||||
except requests.exceptions.ConnectionError:
|
sensors_client.write_points([point])
|
||||||
logging.exception('Error connecting to InfluxDB!')
|
break
|
||||||
return
|
except Exception as e:
|
||||||
|
logging.exception('Error writing to InfluxDB (attempt %s/3): %s', attempt + 1, e)
|
||||||
|
if attempt == 2:
|
||||||
|
controller_message('Failed to write to InfluxDB after 3 attempts: ' + str(e))
|
||||||
|
return
|
||||||
|
time.sleep(1)
|
||||||
|
|
||||||
logging.info('Wrote %s data to InfluxDB: %s', self, data)
|
logging.info('Wrote %s data to InfluxDB: %s', self, data)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user