diff options
-rw-r--r-- | cdsapi/api.py | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/cdsapi/api.py b/cdsapi/api.py index 88a3a8c..6dea7de 100644 --- a/cdsapi/api.py +++ b/cdsapi/api.py @@ -150,6 +150,14 @@ class Client(object): logger = logging.getLogger('cdsapi') + def __enter__(self, **kwargs): + self.__init__(**kwargs) + return self + + def __exit__(self, exc_type, exc_val, exc_tb): + self.session.close() + pass + def __init__(self, url=os.environ.get('CDSAPI_URL'), key=os.environ.get('CDSAPI_KEY'), |