Thanks to visit codestin.com
Credit goes to github.com

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

feat(client): allow custom requests session in InfluxDBClient #807

Merged
merged 2 commits into from
Apr 7, 2020
Merged
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 @@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Add mypy testing framework (#756)
- Add support for messagepack (#734 thx @lovasoa)
- Add support for 'show series' (#357 thx @gaker)
- Add support for custom request session in InfluxDBClient (#360 thx @dschien)

### Changed
- Clean up stale CI config (#755)
Expand Down
10 changes: 9 additions & 1 deletion influxdb/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ class InfluxDBClient(object):
as a single file containing the private key and the certificate, or as
a tuple of both files’ paths, defaults to None
:type cert: str
:param session: allow for the new client request to use an existing
requests Session, defaults to None
:type session: requests.Session

:raises ValueError: if cert is provided but ssl is disabled (set to False)
"""
Expand All @@ -90,6 +93,7 @@ def __init__(self,
pool_size=10,
path='',
cert=None,
session=None,
):
"""Construct a new InfluxDBClient object."""
self.__host = host
Expand All @@ -104,7 +108,11 @@ def __init__(self,

self.__use_udp = use_udp
self.__udp_port = udp_port
self._session = requests.Session()

if not session:
session = requests.Session()

self._session = session
adapter = requests.adapters.HTTPAdapter(
pool_connections=int(pool_size),
pool_maxsize=int(pool_size)
Expand Down