Skip to content

Commit

Permalink
Merge pull request #68 from larsbuntemeyer/requests_cache
Browse files Browse the repository at this point in the history
requests_cache API update

@larsbuntemeyer: there are two outstanding failed tests that we are going to fix in master, so merging this one now.
  • Loading branch information
agstephens committed Apr 19, 2021
2 parents db2bddb + a16ad78 commit ae7a5b9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions pyesgf/search/connection.py
Expand Up @@ -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(
Expand All @@ -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
Expand Down Expand Up @@ -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:
Expand All @@ -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()
Expand Down
4 changes: 2 additions & 2 deletions tests/test_connection.py
Expand Up @@ -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')
Expand All @@ -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')
Expand Down

0 comments on commit ae7a5b9

Please sign in to comment.