diff --git a/influxdb/client.py b/influxdb/client.py index 8ac557d3..adf47697 100644 --- a/influxdb/client.py +++ b/influxdb/client.py @@ -29,6 +29,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 + `_. + :param host: hostname to connect to InfluxDB, defaults to 'localhost' :type host: str :param port: port to connect to InfluxDB, defaults to 8086 @@ -61,6 +64,7 @@ class InfluxDBClient(object): :type proxies: dict :param path: path of InfluxDB on the server to connect, defaults to '' :type path: str + """ def __init__(self, @@ -1055,6 +1059,14 @@ def close(self): if isinstance(self._session, requests.Session): self._session.close() + def __enter__(self): + """For use as context manager""" + pass + + def __exit__(self, _exc_type, _exc_value, _traceback): + """For use as context manager""" + self.close() + def _parse_dsn(dsn): """Parse data source name. pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy