Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions influxdb_client_3/write_client/client/write_api.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
"""Collect and write time series data to InfluxDB Cloud or InfluxDB OSS."""

# coding: utf-8
# TODO Remove after this program no longer supports Python 3.8.*
from __future__ import annotations
import logging
import os
import warnings
Expand Down Expand Up @@ -420,14 +422,15 @@ def _create_batching_pipeline(self) -> tuple[Subject[Any], rx.abc.DisposableBase
# Create batch (concatenation line protocols by \n)
ops.map(lambda group: group.pipe( # type: ignore
ops.to_iterable(),
ops.map(lambda xs: _BatchItem(key=group.key, data=_body_reduce(xs), size=len(xs))))), # type: ignore
ops.map(lambda xs: _BatchItem(key=group.key, data=_body_reduce(xs), size=len(xs))))),
# type: ignore
ops.merge_all())),
# Write data into InfluxDB (possibility to retry if its fail)
ops.filter(lambda batch: batch.size > 0),
ops.map(mapper=lambda batch: self._to_response(data=batch, delay=self._jitter_delay())),
ops.merge_all()) \
.subscribe(self._on_next, self._on_error, self._on_complete)

return subject, disposable

def flush(self):
Expand All @@ -453,7 +456,7 @@ def close(self):
"""Flush data and dispose a batching buffer."""
if self._subject is None:
return # Already closed

self._subject.on_completed()
self._subject.dispose()
self._subject = None
Expand Down
Loading