Skip to content

Even when a cached downloaded file exists, urlopen() is called #8676

@dstndstn

Description

@dstndstn

I'm tracking down a problem using a cached coordinates/sites.json on a read-only filesystem.

An issue I am finding is this:
in astropy/utils/data.py,
get_pkg_data_fileobj
ends up calling
get_readable_fileobj
with a URL, which calls
download_file()

Now, even if the file is already in the cache, on data.py:1005 it ends up calling
with urllib.request.urlopen(conf.dataurl, timeout=timeout) as remote:
_dataurls_to_alias[conf.dataurl] = [conf.dataurl, remote.geturl()]
to find out if the URL is an alias.

Now, okay, this only gets called once per session, but really? Please can you avoid doing this somehow? Pre-fill known aliases for data.astropy.org, maybe? ie, initialize:

_dataurls_to_alias = {'http://data.astropy.org/': ['http://data.astropy.org/', 'https://astropy.stsci.edu/data/']}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions