Skip to content
This repository has been archived by the owner on Apr 22, 2024. It is now read-only.

Commit

Permalink
feat(client): allow custom requests session in InfluxDBClient (#807)
Browse files Browse the repository at this point in the history
* feat(client): enable client request to provide custom requests session

* feat(client): allow custom requests session in InfluxDBClient
  • Loading branch information
sebito91 committed Apr 7, 2020
1 parent ea1b995 commit ad5e5b6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
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

0 comments on commit ad5e5b6

Please sign in to comment.