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

Commit

Permalink
Merge 1a6b291 into f7f30b5
Browse files Browse the repository at this point in the history
  • Loading branch information
sebito91 committed Apr 10, 2020
2 parents f7f30b5 + 1a6b291 commit c9daa68
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Expand Up @@ -23,6 +23,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Add gzip compression for post and response data (#732 thx @KEClaytor)
- Add support for chunked responses in ResultSet (#753 and #538 thx @hrbonz && @psy0rz)
- Add support for empty string fields (#766 thx @gregschrock)
- Add support for context managers to InfluxDBClient (#721 thx @JustusAdam)

### Changed
- Clean up stale CI config (#755)
Expand All @@ -37,6 +38,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Update client to type-set UDP port to int (#651 thx @yifeikong)
- Update batched writing support for all iterables (#746 thx @JayH5)
- Update SeriesHelper to enable class instantiation when not initialized (#772 thx @ocworld)
- Update UDP test case to add proper timestamp to datapoints (#808 thx @shantanoo-desai)

### Removed

Expand Down
12 changes: 12 additions & 0 deletions influxdb/client.py
Expand Up @@ -35,6 +35,9 @@ class InfluxDBClient(object):
connect to InfluxDB. Requests can be made to InfluxDB directly through
the client.
The client supports the use as a `context manager
<https://docs.python.org/3/reference/datamodel.html#context-managers>`_.
:param host: hostname to connect to InfluxDB, defaults to 'localhost'
:type host: str
:param port: port to connect to InfluxDB, defaults to 8086
Expand Down Expand Up @@ -78,6 +81,7 @@ class InfluxDBClient(object):
requests Session, defaults to None
:type session: requests.Session
:raises ValueError: if cert is provided but ssl is disabled (set to False)
"""

def __init__(self,
Expand Down Expand Up @@ -165,6 +169,14 @@ def __init__(self,

self._gzip = gzip

def __enter__(self):
"""Enter function as used by context manager."""
pass

def __exit__(self, _exc_type, _exc_value, _traceback):
"""Exit function as used by context manager."""
self.close()

@property
def _baseurl(self):
return self.__baseurl
Expand Down

0 comments on commit c9daa68

Please sign in to comment.