openmeteo / enhydris

A database with a web interface for the storage and management of hydro/meteorological measurements and time series
GNU Affero General Public License v3.0
18 stars 11 forks source link

No such file or directory: '/var/cache/enhydris/openmeteo/django_cache/...' #481

Closed aptiko closed 11 months ago

aptiko commented 2 years ago

I occasionally receive emails with an error like this:

Traceback (most recent call last):
  File "/opt/enhydris-openhi/venv/lib/python3.9/site-packages/django/core/handlers/exception.py", line 47, in inner
    response = get_response(request)
  File "/opt/enhydris-openhi/venv/lib/python3.9/site-packages/django/core/handlers/base.py", line 181, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/opt/enhydris-openhi/venv/lib/python3.9/site-packages/django/views/decorators/csrf.py", line 54, in wrapped_view
    return view_func(*args, **kwargs)
  File "/opt/enhydris-openhi/venv/lib/python3.9/site-packages/rest_framework/viewsets.py", line 125, in view
    return self.dispatch(request, *args, **kwargs)
  File "/opt/enhydris-openhi/venv/lib/python3.9/site-packages/rest_framework/views.py", line 509, in dispatch
    response = self.handle_exception(exc)
  File "/opt/enhydris-openhi/venv/lib/python3.9/site-packages/rest_framework/views.py", line 469, in handle_exception
    self.raise_uncaught_exception(exc)
  File "/opt/enhydris-openhi/venv/lib/python3.9/site-packages/rest_framework/views.py", line 480, in raise_uncaught_exception
    raise exc
  File "/opt/enhydris-openhi/venv/lib/python3.9/site-packages/rest_framework/views.py", line 506, in dispatch
    response = handler(request, *args, **kwargs)
  File "/opt/enhydris-openhi/venv/lib/python3.9/site-packages/rest_framework/mixins.py", line 56, in retrieve
    return Response(serializer.data)
  File "/opt/enhydris-openhi/venv/lib/python3.9/site-packages/rest_framework/serializers.py", line 548, in data
    ret = super().data
  File "/opt/enhydris-openhi/venv/lib/python3.9/site-packages/rest_framework/serializers.py", line 246, in data
    self._data = self.to_representation(self.instance)
  File "/opt/enhydris-openhi/venv/lib/python3.9/site-packages/rest_framework/serializers.py", line 502, in to_representation
    attribute = field.get_attribute(instance)
  File "/opt/enhydris-openhi/venv/lib/python3.9/site-packages/rest_framework/fields.py", line 457, in get_attribute
    return get_attribute(instance, self.source_attrs)
  File "/opt/enhydris-openhi/venv/lib/python3.9/site-packages/rest_framework/fields.py", line 97, in get_attribute
    instance = getattr(instance, attr)
  File "/opt/enhydris-openhi/enhydris/models/gentity.py", line 228, in last_update
    return cache.get_or_set(f"station_last_update_{self.id}", get_last_update)
  File "/opt/enhydris-openhi/venv/lib/python3.9/site-packages/django/core/cache/backends/base.py", line 173, in get_or_set
    default = default()
  File "/opt/enhydris-openhi/enhydris/models/gentity.py", line 221, in get_last_update
    t_end_date = t.end_date
  File "/opt/enhydris-openhi/enhydris/models/timeseries.py", line 134, in end_date
    return cache.get_or_set(f"timeseries_end_date_{self.id}", get_end_date)
  File "/opt/enhydris-openhi/venv/lib/python3.9/site-packages/django/core/cache/backends/base.py", line 174, in get_or_set
    self.add(key, default, timeout=timeout, version=version)
  File "/opt/enhydris-openhi/venv/lib/python3.9/site-packages/django/core/cache/backends/filebased.py", line 26, in add
    if self.has_key(key, version):
  File "/opt/enhydris-openhi/venv/lib/python3.9/site-packages/django/core/cache/backends/filebased.py", line 94, in has_key
    with open(fname, 'rb') as f:

Exception Type: FileNotFoundError at /api/stations/2197/
Exception Value: [Errno 2] No such file or directory: '/var/cache/enhydris/openmeteo/django_cache/[...].djcache'
aptiko commented 11 months ago

Closing this as it's been some time that I haven't received such an email.