Skip to content
This repository was archived by the owner on Oct 29, 2024. It is now read-only.

Fix issue with cluster on multiple ports #287

Merged
merged 1 commit into from
Jan 29, 2016
Merged
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
15 changes: 13 additions & 2 deletions influxdb/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def __init__(self,
):
"""Construct a new InfluxDBClient object."""
self.__host = host
self._port = port
self.__port = port
self._username = username
self._password = password
self._database = database
Expand Down Expand Up @@ -110,7 +110,7 @@ def __init__(self,
'Accept': 'text/plain'
}

# _baseurl and _host are properties to allow InfluxDBClusterClient
# _baseurl, _host and _port are properties to allow InfluxDBClusterClient
# to override them with thread-local variables
@property
def _baseurl(self):
Expand All @@ -126,6 +126,13 @@ def _host(self):
def _get_host(self):
return self.__host

@property
def _port(self):
return self._get_port()

def _get_port(self):
return self.__port

@staticmethod
def from_DSN(dsn, **kwargs):
"""Return an instance of :class:`~.InfluxDBClient` from the provided
Expand Down Expand Up @@ -806,6 +813,7 @@ def __init__(self,
setattr(self, method, self._make_func(orig_attr))

self._client._get_host = self._get_host
self._client._get_port = self._get_port
self._client._get_baseurl = self._get_baseurl
self._update_client_host(self.hosts[0])

Expand Down Expand Up @@ -856,6 +864,9 @@ def _get_baseurl(self):
def _get_host(self):
return self._thread_local.host

def _get_port(self):
return self._thread_local.port

def _make_func(self, orig_func):

@wraps(orig_func)
Expand Down