This repository was archived by the owner on Oct 29, 2024. It is now read-only.
File tree 2 files changed +14
-0
lines changed
2 files changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -23,6 +23,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
23
23
- Add gzip compression for post and response data (#732 thx @KEClaytor )
24
24
- Add support for chunked responses in ResultSet (#753 and #538 thx @hrbonz && @psy0rz )
25
25
- Add support for empty string fields (#766 thx @gregschrock )
26
+ - Add support for context managers to InfluxDBClient (#721 thx @JustusAdam )
26
27
27
28
### Changed
28
29
- Clean up stale CI config (#755 )
@@ -37,6 +38,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
37
38
- Update client to type-set UDP port to int (#651 thx @yifeikong )
38
39
- Update batched writing support for all iterables (#746 thx @JayH5 )
39
40
- Update SeriesHelper to enable class instantiation when not initialized (#772 thx @ocworld )
41
+ - Update UDP test case to add proper timestamp to datapoints (#808 thx @shantanoo-desai )
40
42
41
43
### Removed
42
44
Original file line number Diff line number Diff line change @@ -35,6 +35,9 @@ class InfluxDBClient(object):
35
35
connect to InfluxDB. Requests can be made to InfluxDB directly through
36
36
the client.
37
37
38
+ The client supports the use as a `context manager
39
+ <https://docs.python.org/3/reference/datamodel.html#context-managers>`_.
40
+
38
41
:param host: hostname to connect to InfluxDB, defaults to 'localhost'
39
42
:type host: str
40
43
:param port: port to connect to InfluxDB, defaults to 8086
@@ -78,6 +81,7 @@ class InfluxDBClient(object):
78
81
requests Session, defaults to None
79
82
:type session: requests.Session
80
83
:raises ValueError: if cert is provided but ssl is disabled (set to False)
84
+
81
85
"""
82
86
83
87
def __init__ (self ,
@@ -165,6 +169,14 @@ def __init__(self,
165
169
166
170
self ._gzip = gzip
167
171
172
+ def __enter__ (self ):
173
+ """Enter function as used by context manager."""
174
+ pass
175
+
176
+ def __exit__ (self , _exc_type , _exc_value , _traceback ):
177
+ """Exit function as used by context manager."""
178
+ self .close ()
179
+
168
180
@property
169
181
def _baseurl (self ):
170
182
return self .__baseurl
You can’t perform that action at this time.
0 commit comments