Skip to content

Commit ee950de

Browse files
committed
Merge pull request influxdata#287 from PierreF/cluster-client-threadsafe
Fix issue with cluster on multiple ports (Thanks @PierreF !)
2 parents 0cc8d66 + 9b4ea84 commit ee950de

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

influxdb/client.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ def __init__(self,
7676
):
7777
"""Construct a new InfluxDBClient object."""
7878
self.__host = host
79-
self._port = port
79+
self.__port = port
8080
self._username = username
8181
self._password = password
8282
self._database = database
@@ -110,7 +110,7 @@ def __init__(self,
110110
'Accept': 'text/plain'
111111
}
112112

113-
# _baseurl and _host are properties to allow InfluxDBClusterClient
113+
# _baseurl, _host and _port are properties to allow InfluxDBClusterClient
114114
# to override them with thread-local variables
115115
@property
116116
def _baseurl(self):
@@ -126,6 +126,13 @@ def _host(self):
126126
def _get_host(self):
127127
return self.__host
128128

129+
@property
130+
def _port(self):
131+
return self._get_port()
132+
133+
def _get_port(self):
134+
return self.__port
135+
129136
@staticmethod
130137
def from_DSN(dsn, **kwargs):
131138
"""Return an instance of :class:`~.InfluxDBClient` from the provided
@@ -806,6 +813,7 @@ def __init__(self,
806813
setattr(self, method, self._make_func(orig_attr))
807814

808815
self._client._get_host = self._get_host
816+
self._client._get_port = self._get_port
809817
self._client._get_baseurl = self._get_baseurl
810818
self._update_client_host(self.hosts[0])
811819

@@ -856,6 +864,9 @@ def _get_baseurl(self):
856864
def _get_host(self):
857865
return self._thread_local.host
858866

867+
def _get_port(self):
868+
return self._thread_local.port
869+
859870
def _make_func(self, orig_func):
860871

861872
@wraps(orig_func)

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy