22import sys
33import time
44
5- from influxdb_client_3 import InfluxDBClient3
6-
5+ from influxdb_client_3 import InfluxDBClient3 , write_client_options
76
87"""
98This example shows how to set query and write timeouts.
2322DEFAULT_DATABASE = 'test-data'
2423
2524
25+ def handle_write_error_cb (rd , rt , rx ):
26+ print (f"Got a write error: { rd } , { rt } , { rx } " )
27+
28+
2629def main (w_to : int , q_to : int ) -> None :
2730 print (f"main { w_to } , { q_to } " )
2831 lp_data = "timeout_example,location=terra fVal=3.14,iVal=42i"
@@ -31,7 +34,10 @@ def main(w_to: int, q_to: int) -> None:
3134 token = DEFAULT_TOKEN ,
3235 database = DEFAULT_DATABASE ,
3336 write_timeout = w_to ,
34- query_timeout = q_to
37+ query_timeout = q_to ,
38+ write_client_options = write_client_options (
39+ error_handler = handle_write_error_cb
40+ )
3541 ) as client :
3642
3743 try :
@@ -64,6 +70,7 @@ def main(w_to: int, q_to: int) -> None:
6470 print (f"Got exception on query: { e } " )
6571
6672
73+ # To force timeout errors supply the corresponding command line arguments
6774if __name__ == "__main__" :
6875 w_ct = DEFAULT_WRITE_TIMEOUT
6976 q_ct = DEFAULT_QUERY_TIMEOUT
0 commit comments