earthobservations / wetterdienst

Open weather data for humans.
https://wetterdienst.readthedocs.io/
MIT License
358 stars 55 forks source link

dbm.error: db file doesn't exist; use 'c' or 'n' flag to create a new db #244

Closed amotl closed 3 years ago

amotl commented 3 years ago

Describe the bug After switching back to my regular development environment based on vanilla Python 3.8 from the micromamba environment for researching into #241, Wetterdienst croaks again. Accessing the cache from there already tripped #242.

To reproduce

  1. Follow the installation at https://github.com/earthobservations/wetterdienst/issues/241#issuecomment-731811937.
  2. Run some invocation of Wetterdienst.
  3. Switch back to environment based on vanilla Python.
  4. Run some invocation of Wetterdienst.

Expected behavior Installing and invoking wetterdienst should just work (TM).

Version information OS: macOS Environment: Vanilla Python

$ wetterdienst --version
wetterdienst 0.10.1
$ python -V
Python 3.8.6

Additional context Dogpile cache based on dbmfile strikes again. See also #217, #232, #233 and #242.

Full traceback

Traceback (most recent call last):
  File "/Users/amo/Library/Caches/pypoetry/virtualenvs/wetterdienst-EkOFQaO8-py3.8/bin/wetterdienst", line 33, in <module>
    sys.exit(load_entry_point('wetterdienst', 'console_scripts', 'wetterdienst')())
  File "/Users/amo/dev/earthobservations/wetterdienst/wetterdienst/cli.py", line 234, in run
    df = get_nearby(options)
  File "/Users/amo/dev/earthobservations/wetterdienst/wetterdienst/cli.py", line 341, in get_nearby
    nearby_stations = DWDObservationSites(
  File "/Users/amo/dev/earthobservations/wetterdienst/wetterdienst/core/sites.py", line 154, in nearby_radius
    metadata = self.all()
  File "/Users/amo/dev/earthobservations/wetterdienst/wetterdienst/core/sites.py", line 51, in all
    metadata = self._all()
  File "/Users/amo/dev/earthobservations/wetterdienst/wetterdienst/dwd/observations/api.py", line 422, in _all
    metadata = metadata_for_climate_observations(
  File "/Users/amo/dev/earthobservations/wetterdienst/wetterdienst/dwd/observations/stations.py", line 43, in metadata_for_climate_observations
    meta_index = create_meta_index_for_climate_observations(
  File "<decorator-gen-3>", line 2, in create_meta_index_for_climate_observations
  File "/Users/amo/Library/Caches/pypoetry/virtualenvs/wetterdienst-EkOFQaO8-py3.8/lib/python3.8/site-packages/dogpile/cache/region.py", line 1356, in get_or_create_for_user_func
    return self.get_or_create(
  File "/Users/amo/Library/Caches/pypoetry/virtualenvs/wetterdienst-EkOFQaO8-py3.8/lib/python3.8/site-packages/dogpile/cache/region.py", line 954, in get_or_create
    with Lock(
  File "/Users/amo/Library/Caches/pypoetry/virtualenvs/wetterdienst-EkOFQaO8-py3.8/lib/python3.8/site-packages/dogpile/lock.py", line 185, in __enter__
    return self._enter()
  File "/Users/amo/Library/Caches/pypoetry/virtualenvs/wetterdienst-EkOFQaO8-py3.8/lib/python3.8/site-packages/dogpile/lock.py", line 87, in _enter
    value = value_fn()
  File "/Users/amo/Library/Caches/pypoetry/virtualenvs/wetterdienst-EkOFQaO8-py3.8/lib/python3.8/site-packages/dogpile/cache/region.py", line 899, in get_value
    value = self.backend.get(key)
  File "/Users/amo/Library/Caches/pypoetry/virtualenvs/wetterdienst-EkOFQaO8-py3.8/lib/python3.8/site-packages/dogpile/cache/backends/file.py", line 221, in get
    with self._dbm_file(False) as dbm:
  File "/Users/amo/.pyenv/versions/3.8.5/lib/python3.8/contextlib.py", line 113, in __enter__
    return next(self.gen)
  File "/Users/amo/Library/Caches/pypoetry/virtualenvs/wetterdienst-EkOFQaO8-py3.8/lib/python3.8/site-packages/dogpile/cache/backends/file.py", line 216, in _dbm_file
    dbm = self.dbmmodule.open(self.filename, "w" if write else "r")
  File "/Users/amo/.pyenv/versions/3.8.5/lib/python3.8/dbm/__init__.py", line 85, in open
    raise error[0]("db file doesn't exist; "
dbm.error: db file doesn't exist; use 'c' or 'n' flag to create a new db
amotl commented 3 years ago

Like with similar errors of this kind, this issue can be resolved by purging the cache directory, like rm -r ~/Library/Caches/wetterdienst.