Skip to content

Asynchronous client ignoring write precision when set on Point #669

Closed
@lundaw

Description

@lundaw

Specifications

  • Client Version: 1.46.0
  • InfluxDB Version: 2.7.10

Code sample to reproduce problem

import asyncio

from influxdb_client import Point, WritePrecision
from influxdb_client.client.influxdb_client_async import InfluxDBClientAsync

_HOST = "http://localhost:8086"
_ORG = "primary"
_TOKEN = "token"
_BUCKET = "MY_BUCKET"
_TIMESTAMP = 1725588000000 # milliseconds, september 6th

async def main() -> None:
  p = Point("debug").field("myval", 42).time(_TIMESTAMP, WritePrecision.MS)

  client = InfluxDBClientAsync(url=_HOST, token=_TOKEN, org=_ORG)
  write_api = client.write_api()
  await write_api.write(bucket=_BUCKET, record=p)
  await client.close()

if __name__ == "__main__":
  asyncio.run(main())

Expected behavior

The write with InfluxDBClientAsync to work the same as InfluxDBClient does with Point defined write precision.

Actual behavior

The InfluxDBClientAsync does not respect the Point write precision, instead defaults to and uses DEFAULT_WRITE_PRECISION.

Additional info

If the write precision is explicitly stated in the write_api.write call, it is handled correctly. Also the docs for the function states that Point data takes precedence which does not happen.

Looking into the calls, I noticed that even though the docstring says that, the self._serialize call in the WriteApiAsync.write has the precision_from_point arguments is set explicitly false. The self._serialize call does the extraction right, but the body is built incorrectly because it only uses the write_precision of the function.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions