首页 > 解决方案 > 使用 write_points 调用 Python influxdb-python,是否有任何可重试的错误?

问题描述

在我的客户端应用程序中使用 influxdb-python 5.3.1 和 influxdb 服务器版本 1.6.4,当我使用 write_points 调用写入数据时,是否有任何可重试的异常?例如:

influx_conn = influxdb.InfluxDBClient(host='my_influxdb_server', username='mylogin', password=mypassword)
influx_monitored_data_points=[]
thing_being_monitored="xyzzy"
# Load up influx_monitored_data_points with data points for thing_being_monitored
try:
  influx_conn.write_points(influx_monitored_data_points)
except:
  print(f"Error writing monitoring data for {thing_being_monitored} to InfluxDB 'my_influxdb_server'")
  raise  # re-raise the error to print out all the gory details

我是否应该添加任何“except specific_exception :”子句来捕获并重试现有连接上的 write_points?

是否有其他错误表明我应该关闭连接并在重新打开之前等待,然后再次使用相同的数据重试 write_points?

此外,对于我不重试的错误,我可以假设 raise 将始终存在于程序中,还是应该在 raise 之后添加和显式 sys.exit() 调用?

我是 Python 新手,请谅解。提前致谢

标签: pythoninfluxdbinfluxdb-python

解决方案


推荐阅读