Skip to content

Proxy warning at boot time #14120

@etj

Description

@etj

At boot, GeoNode prints this warning:

[...]/lib/python3.10/site-packages/django/db/backends/utils.py:101: RuntimeWarning: Accessing the database during app initialization is discouraged. To fix this warning, avoid executing queries in AppConfig.ready() or when your app modules are imported.
  warnings.warn(self.APPS_NOT_READY_WARNING_MSG, category=RuntimeWarning)

It is caused by the proxy module, which in the ready method calls

def run_setup_hooks(*args, **kwargs):
proxy_urls_registry.initialize()

which preloads some data:

for link in Link.objects.filter(resource__sourcetype="REMOTE", link_type__in=PROXIED_LINK_TYPES):

Probably the initialize() call can be avoided, since the cache is checked and reloaded when it is accessed:

if (
self._last_registry_load is None
or (now() - self._last_registry_load).days >= self._registry_reload_threshold
):
self.initialize()
return self.proxy_allowed_hosts

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions