jayvdb / pypidb

PyPI client side database with SCM/VCS URLs
Apache License 2.0
13 stars 3 forks source link

diskcache: sqlite3.OperationalError: database is locked #92

Open jayvdb opened 4 years ago

jayvdb commented 4 years ago

Running two instances together may result in an exception. I frequently do this, and this is the first and only time it has occurred.

py38 run-test: commands[0] | coverage run -m pypidb requests-threads
Traceback (most recent call last):
  File "/home/jayvdb/projects/pypi2vcs/release/pypidb/__main__.py", line 4, in <module>
    cli()
  File "/home/jayvdb/projects/pypi2vcs/release/.tox/py38/lib/python3.8/site-packages/click/core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "/home/jayvdb/projects/pypi2vcs/release/.tox/py38/lib/python3.8/site-packages/click/core.py", line 782, in main
    rv = self.invoke(ctx)
  File "/home/jayvdb/projects/pypi2vcs/release/.tox/py38/lib/python3.8/site-packages/click/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/jayvdb/projects/pypi2vcs/release/.tox/py38/lib/python3.8/site-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/home/jayvdb/projects/pypi2vcs/release/pypidb/cli.py", line 13, in cli
    db = Database()
  File "/home/jayvdb/projects/pypi2vcs/release/pypidb/_db.py", line 101, in __init__
    from ._pypi import Converter
  File "/home/jayvdb/projects/pypi2vcs/release/pypidb/_pypi.py", line 24, in <module>
    from ._rules import DefaultRule, _find_named_repo, rules
  File "/home/jayvdb/projects/pypi2vcs/release/pypidb/_rules.py", line 49, in <module>
    dns_cache = NoExpirationDiskCache(directory=dns_cache_dirpath, min_ttl=NO_EXPIRY)
  File "/home/jayvdb/projects/pypi2vcs/release/.tox/py38/lib/python3.8/site-packages/dns_cache/diskcache.py", line 16, in __init__
    super(DiskCache, self).__init__(*args, **kwargs)
  File "/home/jayvdb/projects/pypi2vcs/release/.tox/py38/lib/python3.8/site-packages/dns_cache/diskcache.py", line 11, in __init__
    self.data = dc.Cache(directory)
  File "/home/jayvdb/projects/pypi2vcs/release/.tox/py38/lib/python3.8/site-packages/diskcache/core.py", line 528, in __init__
    sql(query, (key, value))
  File "/home/jayvdb/projects/pypi2vcs/release/.tox/py38/lib/python3.8/site-packages/diskcache/core.py", line 693, in _execute_with_retry
    return sql(statement, *args, **kwargs)
sqlite3.OperationalError: database is locked
jayvdb commented 4 years ago

It happened again, and the other process running atm is stuck on pytest-rerunfailures

tests/test_failures.py ...........................................................................................R

Lock resolved after the other processes finished.