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
The util.url.fetch_url and util.url.fetch_url_text functions are supposed to have an optional cache ("Mapping cache: An optional cache. If the URL can be found in the cache, return the cache contents.", as per the documentation)
However, in the current implementation there will always be a cache, which I believe was not the intention.
The root cause is using {} as default for the cache argument; rather than re-instantiating a new dictionary every time the function is called, this re-uses the same dictionary between function calls.
You're absolutely right! That's one of the things in Python I keep forgetting about. There will be similar issues; I'll go through the code to find them.
The
util.url.fetch_url
andutil.url.fetch_url_text
functions are supposed to have an optional cache ("Mapping cache: An optional cache. If the URL can be found in the cache, return the cache contents.", as per the documentation)However, in the current implementation there will always be a cache, which I believe was not the intention.
The root cause is using
{}
as default for thecache
argument; rather than re-instantiating a new dictionary every time the function is called, this re-uses the same dictionary between function calls.See e.g. https://docs.python-guide.org/writing/gotchas/#mutable-default-arguments for details
A simple fix would be:
Expected Behaviour
URL contents should not be cached unless the
cache
argument is provided.Minimal Example Spec
Actual Behaviour
URL contents get cached if no
cache
argument is provided.Steps to Reproduce
Given a file
test.yaml
with the following contents:and the following program:
we get the following output:
Change the file to e.g.
and then re-run the
fetch_url(url)
part. I would expect the output to change, but you still get:Environment
@jfinkhaeuser
The text was updated successfully, but these errors were encountered: