Skip to content

Commit 5eb19df

Browse files
authored
docs: clarify how to flush data at the end of script (#174)
* docs: clarify how to flush data at the end of script * docs: added close() method to WriteApi
1 parent 2805e88 commit 5eb19df

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

README.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,8 @@ Writes
215215
The `WriteApi <https://github.com/influxdata/influxdb-client-python/blob/master/influxdb_client/client/write_api.py>`_ supports synchronous, asynchronous and batching writes into InfluxDB 2.0.
216216
The data should be passed as a `InfluxDB Line Protocol <https://docs.influxdata.com/influxdb/latest/write_protocols/line_protocol_tutorial/>`_\ , `Data Point <https://github.com/influxdata/influxdb-client-python/blob/master/influxdb_client/client/write/point.py>`_ or Observable stream.
217217

218+
**Important: The WriteApi in batching mode (default mode) is suppose to run as a singleton. To flush all your data you should call ``_write_client.close()`` at the end of your script.**
219+
218220
*The default instance of WriteApi use batching.*
219221

220222
The data could be written as

influxdb_client/client/write_api.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,10 @@ def flush(self):
260260
# TODO
261261
pass
262262

263+
def close(self):
264+
"""Flush data and dispose a batching buffer."""
265+
self.__del__()
266+
263267
def __del__(self):
264268
"""Close WriteApi."""
265269
if self._subject:

0 commit comments

Comments
 (0)