You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is an idea to partly address one of the problems with install_cache(): accidentally caching things you didn't intend to. This could potentially be more convenient than using requests_cache.enabled() for cases where you just want to cache all requests made from a single module.
# package/module_2.pyfromrequestsimportgetresponse=get('https://url.com') # not cached
Using CachedSession directly is still the better option, but this would be a nice safety measure for users who prefer the convenience of install_cache().
This should be doable with inspection. It would work slightly differently than install_cache() currently does, by patching requests.api.request() to use a CachedSession if the calling context is from the same module that patched it, or a regular requests.Session otherwise. This would apply only to the static wrapper functions (requests.get(), etc.), not Session usage.
This could potentially be done from multiple modules at once, by adding and updating an attribute containing a list of allowed modules. uninstall_cache() would also need to take into account.
The text was updated successfully, but these errors were encountered:
This is an idea to partly address one of the problems with
install_cache()
: accidentally caching things you didn't intend to. This could potentially be more convenient than usingrequests_cache.enabled()
for cases where you just want to cache all requests made from a single module.It would look something like:
Using
CachedSession
directly is still the better option, but this would be a nice safety measure for users who prefer the convenience ofinstall_cache()
.This should be doable with inspection. It would work slightly differently than
install_cache()
currently does, by patchingrequests.api.request()
to use aCachedSession
if the calling context is from the same module that patched it, or a regularrequests.Session
otherwise. This would apply only to the static wrapper functions (requests.get()
, etc.), not Session usage.This could potentially be done from multiple modules at once, by adding and updating an attribute containing a list of allowed modules.
uninstall_cache()
would also need to take into account.The text was updated successfully, but these errors were encountered: