From a41c5248682ef7702c7e4d74bf13d952d709f080 Mon Sep 17 00:00:00 2001 From: Lars Buntemeyer Date: Sat, 10 Apr 2021 01:51:50 +0200 Subject: [PATCH 1/2] requests_cache API update --- pyesgf/search/connection.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pyesgf/search/connection.py b/pyesgf/search/connection.py index d186082..160ec11 100644 --- a/pyesgf/search/connection.py +++ b/pyesgf/search/connection.py @@ -95,7 +95,7 @@ def __init__(self, url, distrib=True, cache=None, timeout=120, def open(self): if (isinstance(self._passed_session, requests.Session) or isinstance( - self._passed_session, requests_cache.core.CachedSession)): + self._passed_session, requests_cache.CachedSession)): self.session = self._passed_session else: self.session = create_single_session( @@ -115,7 +115,7 @@ def __exit__(self, type, value, traceback): def close(self): # Close the session if not (isinstance(self._passed_session, requests.Session) or isinstance( - self._passed_session, requests_cache.core.CachedSession)): + self._passed_session, requests_cache.CachedSession)): self.session.close() self._isopen = False return @@ -361,7 +361,7 @@ def create_single_session(cache=None, expire_after=datetime.timedelta(hours=1), """ if cache is not None: try: - session = (requests_cache.core + session = (requests_cache .CachedSession(cache, expire_after=expire_after)) except DatabaseError: @@ -370,7 +370,7 @@ def create_single_session(cache=None, expire_after=datetime.timedelta(hours=1), os.remove(cache) except Exception: pass - session = (requests_cache.core + session = (requests_cache .CachedSession(cache, expire_after=expire_after)) else: session = requests.Session() From a16ad78f7c036aeadf1b905158a7bd2d75535770 Mon Sep 17 00:00:00 2001 From: Lars Buntemeyer Date: Sat, 10 Apr 2021 01:55:35 +0200 Subject: [PATCH 2/2] test update for requests_cache API update --- tests/test_connection.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_connection.py b/tests/test_connection.py index 45f934a..a5691e7 100644 --- a/tests/test_connection.py +++ b/tests/test_connection.py @@ -68,7 +68,7 @@ def test_passed_session(self): def test_passed_cached_session(self): import requests_cache td = datetime.timedelta(hours=1) - session = requests_cache.core.CachedSession(self.cache, + session = requests_cache.CachedSession(self.cache, expire_after=td) conn = SearchConnection(self.test_service, session=session) context = conn.new_context(project='cmip5') @@ -77,7 +77,7 @@ def test_passed_cached_session(self): def test_connection_instance(self): import requests_cache td = datetime.timedelta(hours=1) - session = requests_cache.core.CachedSession(self.cache, + session = requests_cache.CachedSession(self.cache, expire_after=td) with SearchConnection(self.test_service, session=session) as conn: context = conn.new_context(project='cmip5')