Skip to content
Open
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
### Bug Fixes

1. [#706](https://github.com/influxdata/influxdb-client-python/pull/706): Use logger instead logging.
1. [#686](https://github.com/influxdata/influxdb-client-python/issues/686): Stop `default_tags` from one client leaking into other clients' `WriteApi` (shared mutable default `PointSettings`).

## 1.50.0 [2026-01-23]

Expand Down
3 changes: 2 additions & 1 deletion influxdb_client/client/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -441,8 +441,9 @@ def _build_flux_ast(params: dict = None, profilers: List[str] = None):

class _BaseWriteApi(object):
def __init__(self, influxdb_client, point_settings=None):
from influxdb_client.client.write_api import PointSettings
self._influxdb_client = influxdb_client
self._point_settings = point_settings
self._point_settings = point_settings if point_settings is not None else PointSettings()
self._write_service = WriteService(influxdb_client.api_client)
if influxdb_client.default_tags:
for key, value in influxdb_client.default_tags.items():
Expand Down
4 changes: 2 additions & 2 deletions influxdb_client/client/influxdb_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from influxdb_client.client.query_api import QueryApi, QueryOptions
from influxdb_client.client.tasks_api import TasksApi
from influxdb_client.client.users_api import UsersApi
from influxdb_client.client.write_api import WriteApi, WriteOptions, PointSettings
from influxdb_client.client.write_api import WriteApi, WriteOptions

logger = logging.getLogger('influxdb_client.client.influxdb_client')

Expand Down Expand Up @@ -210,7 +210,7 @@ def from_env_properties(cls, debug=None, enable_gzip=False, **kwargs):
"""
return InfluxDBClient._from_env_properties(debug=debug, enable_gzip=enable_gzip, **kwargs)

def write_api(self, write_options=WriteOptions(), point_settings=PointSettings(), **kwargs) -> WriteApi:
def write_api(self, write_options=WriteOptions(), point_settings=None, **kwargs) -> WriteApi:
"""
Create Write API instance.

Expand Down
3 changes: 1 addition & 2 deletions influxdb_client/client/influxdb_client_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
from influxdb_client.client.delete_api_async import DeleteApiAsync
from influxdb_client.client.query_api import QueryOptions
from influxdb_client.client.query_api_async import QueryApiAsync
from influxdb_client.client.write_api import PointSettings
from influxdb_client.client.write_api_async import WriteApiAsync

logger = logging.getLogger('influxdb_client.client.influxdb_client_async')
Expand Down Expand Up @@ -273,7 +272,7 @@ def query_api(self, query_options: QueryOptions = QueryOptions()) -> QueryApiAsy
"""
return QueryApiAsync(self, query_options)

def write_api(self, point_settings=PointSettings()) -> WriteApiAsync:
def write_api(self, point_settings=None) -> WriteApiAsync:
"""
Create an asynchronous Write API instance.

Expand Down
2 changes: 1 addition & 1 deletion influxdb_client/client/write_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ class WriteApi(_BaseWriteApi):
def __init__(self,
influxdb_client,
write_options: WriteOptions = WriteOptions(),
point_settings: PointSettings = PointSettings(),
point_settings: PointSettings = None,
**kwargs) -> None:
"""
Initialize defaults.
Expand Down
2 changes: 1 addition & 1 deletion influxdb_client/client/write_api_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class WriteApiAsync(_BaseWriteApi):
write_api = client.write_api()
"""

def __init__(self, influxdb_client, point_settings: PointSettings = PointSettings()) -> None:
def __init__(self, influxdb_client, point_settings: PointSettings = None) -> None:
"""
Initialize defaults.

Expand Down
19 changes: 19 additions & 0 deletions tests/test_InfluxDBClient.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,25 @@ def test_default_conf(self):
self.client = InfluxDBClient(url="http://localhost:8086", token="my-token", org="my-org")
self.assertIsNotNone(self.client.api_client.configuration.connection_pool_maxsize)

def test_default_tags_not_shared_between_clients(self):
# https://github.com/influxdata/influxdb-client-python/issues/686
# default_tags from one client must not leak into another client's WriteApi.
self.client = InfluxDBClient(url="http://localhost:8086", token="my-token", org="my-org")
write_plain_before = self.client.write_api(write_options=SYNCHRONOUS)

client_tagged = InfluxDBClient(url="http://localhost:8086", token="my-token", org="my-org",
default_tags={"id": "client-tagged"})
client_tagged.write_api(write_options=SYNCHRONOUS)

write_plain_after = self.client.write_api(write_options=SYNCHRONOUS)

try:
self.assertEqual({}, write_plain_before._point_settings.defaultTags)
self.assertEqual({}, write_plain_after._point_settings.defaultTags)
self.assertIsNot(write_plain_before._point_settings, write_plain_after._point_settings)
finally:
client_tagged.close()

def test_TrailingSlashInUrl(self):
self.client = InfluxDBClient(url="http://localhost:8086", token="my-token", org="my-org")
self.assertEqual('http://localhost:8086', self.client.api_client.configuration.host)
Expand Down