Skip to content

Commit

Permalink
pyproject, abi3audit: use requests-cache instead of cachecontrol
Browse files Browse the repository at this point in the history
Less configuration, doesn't use multiple open files.

Signed-off-by: William Woodruff <[email protected]>
  • Loading branch information
woodruffw committed Oct 5, 2022
1 parent 190c702 commit 81ee88f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 18 deletions.
22 changes: 5 additions & 17 deletions abi3audit/_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,14 @@
Caching middleware for `abi3audit`.
"""

from pathlib import Path
from requests_cache import CachedSession

import requests
from cachecontrol import CacheControl
from cachecontrol.caches import FileCache

_ABI3AUDIT_INTERNAL_CACHE = Path.home() / ".cache" / "abi3audit"


def caching_session() -> CacheControl:
def caching_session() -> CachedSession:
"""
Return a `requests` style session, with suitable caching middleware.
"""

# We limit the number of redirects to 5, since the services we connect to
# should really never redirect more than once or twice.
inner_session = requests.Session()
inner_session.max_redirects = 5

return CacheControl(
inner_session,
cache=FileCache(_ABI3AUDIT_INTERNAL_CACHE),
)
session = CachedSession("abi3audit", use_cache_dir=True)
session.max_redirects = 5
return session
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ classifiers = [
]
dependencies = [
"abi3info >= 0.0.5",
"CacheControl[filecache]>=0.12.10",
"kaitaistruct ~= 0.10",
"packaging ~= 21.3",
"pefile >= 2022.5.30",
"pyelftools >= 0.29",
"requests ~= 2.28.1",
"requests-cache ~= 0.9.6",
"rich ~= 12.5.1",
]
requires-python = ">=3.10"
Expand Down

0 comments on commit 81ee88f

Please sign in to comment.