pytest-testmon: sqlite3.OperationalError: database is locked
Hi there! I’m looking into using pytest-testmon, but have bumped into this error a few times:
INTERNALERROR> Traceback (most recent call last):
INTERNALERROR> File "/.venv/lib/python3.10/site-packages/_pytest/main.py", line 266, in wrap_session
INTERNALERROR> config._do_configure()
INTERNALERROR> File "/.venv/lib/python3.10/site-packages/_pytest/config/__init__.py", line 1037, in _do_configure
INTERNALERROR> self.hook.pytest_configure.call_historic(kwargs=dict(config=self))
INTERNALERROR> File "/.venv/lib/python3.10/site-packages/pluggy/_hooks.py", line 277, in call_historic
INTERNALERROR> res = self._hookexec(self.name, self.get_hookimpls(), kwargs, False)
INTERNALERROR> File "/.venv/lib/python3.10/site-packages/pluggy/_manager.py", line 80, in _hookexec
INTERNALERROR> return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
INTERNALERROR> File "/.venv/lib/python3.10/site-packages/pluggy/_callers.py", line 60, in _multicall
INTERNALERROR> return outcome.get_result()
INTERNALERROR> File "/.venv/lib/python3.10/site-packages/pluggy/_result.py", line 60, in get_result
INTERNALERROR> raise ex[1].with_traceback(ex[2])
INTERNALERROR> File "/.venv/lib/python3.10/site-packages/pluggy/_callers.py", line 39, in _multicall
INTERNALERROR> res = hook_impl.function(*args)
INTERNALERROR> File "/.venv/lib/python3.10/site-packages/testmon/pytest_testmon.py", line 189, in pytest_configure
INTERNALERROR> init_testmon_data(config)
INTERNALERROR> File "/.venv/lib/python3.10/site-packages/testmon/pytest_testmon.py", line 126, in init_testmon_data
INTERNALERROR> testmon_data = TestmonData(
INTERNALERROR> File "/.venv/lib/python3.10/site-packages/testmon/testmon_core.py", line 139, in __init__
INTERNALERROR> self.db = db.DB(self.datafile, self.environment)
INTERNALERROR> File "/.venv/lib/python3.10/site-packages/testmon/db.py", line 49, in __init__
INTERNALERROR> connection = connect(datafile)
INTERNALERROR> File "/.venv/lib/python3.10/site-packages/testmon/db.py", line 38, in connect
INTERNALERROR> connection.execute("PRAGMA synchronous = OFF")
INTERNALERROR> sqlite3.OperationalError: database is locked
I’m running watchdog pytest.main, which will sometimes send a SIGKILL to pytest if it’s taking too long, and I’m wondering whether this might create a broken state. The only way I’ve been able to successfully resolve this issue is by running rm -rf .testmondata*.
About this issue
- Original URL
- State: closed
- Created a year ago
- Comments: 26 (14 by maintainers)
Commits related to this issue
- Keeping the temporary tables really temporary. This should help with re #203 and re #222 — committed to tarpas/pytest-testmon by tarpas 8 months ago
- Open testmondata in readonly mode in xdist workers. This hopefully fixes re #203 sqlite3.OperationalError: database is locked . — committed to tarpas/pytest-testmon by tarpas 8 months ago
@christianbundy @smitp It would be great if you could try the latest pre-release and report if the problem is fixed.
There is a pre-release ta py pi with https://github.com/tarpas/pytest-testmon/commit/a34500e2ab47a260378ee8a60653ddb7f644ed64 . There is a big hope this should go away.
Yup! I’m running in Docker (based on
python:3.10.8-slim-bullseye), my dependencies (all using the latest patch versions) are:Pytest options:
My
conftest.py:And my command: