diff --git a/influxdb/client.py b/influxdb/client.py index bca047a8..c602bde5 100644 --- a/influxdb/client.py +++ b/influxdb/client.py @@ -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 @@ -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): @@ -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 @@ -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]) @@ -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)