Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Implement flush in write_api#678

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
minsungoh wants to merge3 commits intoinfluxdata:master
base:master
Choose a base branch
Loading
fromminsungoh:master
Open
Show file tree
Hide file tree
Changes fromall 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
4 changes: 4 additions & 0 deletionsCHANGELOG.md
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -22,6 +22,10 @@
2. [#674](https://github.com/influxdata/influxdb-client-python/pull/674): Add type linting to client.flux_table.FluxTable, remove duplicated `from pathlib import Path` at setup.py
3. [#675](https://github.com/influxdata/influxdb-client-python/pull/675): Ensures WritePrecision in Point is preferred to `DEFAULT_PRECISION`

### Features

1. [#678](https://github.com/influxdata/influxdb-client-python/pull/678): Implement flush method in `Write_api`

## 1.46.0 [2024-09-13]

### Bug Fixes
Expand Down
6 changes: 3 additions & 3 deletionsinfluxdb_client/client/write_api.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -387,8 +387,8 @@ def write_payload(payload):

def flush(self):
"""Flush data."""
# TODO
pass
if self._subject:
self._subject.on_completed()

def close(self):
"""Flush data and dispose a batching buffer."""
Expand All@@ -411,8 +411,8 @@ def __exit__(self, exc_type, exc_val, exc_tb):

def __del__(self):
"""Close WriteApi."""
self.flush()
if self._subject:
self._subject.on_completed()
self._subject.dispose()
self._subject = None

Expand Down
24 changes: 24 additions & 0 deletionstests/test_WriteApiBatching.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -17,6 +17,7 @@
from influxdb_client.client.exceptions import InfluxDBError
from influxdb_client.client.write.point import Point
from influxdb_client.client.write_api import WriteOptions, WriteApi, PointSettings
from tests.base_test import BaseTest


class BatchingWriteTest(unittest.TestCase):
Expand DownExpand Up@@ -736,6 +737,29 @@ def __call__(self, conf: (str, str, str), data: str, error: InfluxDBError):
self.assertIsInstance(callback.error, InfluxDBError)
self.assertEqual(429, callback.error.response.status)

class BatchingWriteFlushTest(BaseTest):

def setUp(self):
return super().setUp()

def test_flush(self):
write_client = self.client.write_api()

bucket = self.create_test_bucket()

write_client.write(bucket.name, self.org, "h2o_feet,location=coyote_creek level\\ water_level=1 1")

write_client.flush()

time.sleep(1)

query = 'from(bucket:"' + bucket.name + '") |> range(start: 1970-01-01T00:00:00.000000001Z)'
flux_result = self.client.query_api().query(query)

self.assertEqual(1, len(flux_result))

self.delete_test_bucket(bucket)


if __name__ == '__main__':
unittest.main()
Loading

[8]ページ先頭

©2009-2025 Movatter.jp