Skip to content

Commit 1be7d68

Browse files
committed
Retry in the case of failures. #1010
PyPy seems prone to intermittent SQLite failures. An immediate retry avoids them. Not great, but it works.
1 parent 104d51e commit 1be7d68

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

CHANGES.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,14 @@ Unreleased
2727
- When using ``--source`` on a large source tree, v5.x was slower than previous
2828
versions. This performance regression is now fixed, closing `issue 1037`_.
2929

30+
- Mysterious SQLite errors can happen on PyPy, as reported in `issue 1010`_. An
31+
immediate retry seems to fix the problem, although it is an unsatisfying
32+
solution.
33+
3034
- Continuous integration has moved from Travis and AppVeyor to GitHub Actions.
3135

3236
.. _issue 1037: https://github.com/nedbat/coveragepy/issues/1037
37+
.. _issue 1010: https://github.com/nedbat/coveragepy/issues/1010
3338

3439

3540
.. _changes_53:

coverage/sqldata.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1056,7 +1056,13 @@ def execute(self, sql, parameters=()):
10561056
tail = " with {!r}".format(parameters) if parameters else ""
10571057
self.debug.write("Executing {!r}{}".format(sql, tail))
10581058
try:
1059-
return self.con.execute(sql, parameters)
1059+
try:
1060+
return self.con.execute(sql, parameters)
1061+
except Exception:
1062+
# In some cases, an error might happen that isn't really an
1063+
# error. Try again immediately.
1064+
# https://github.com/nedbat/coveragepy/issues/1010
1065+
return self.con.execute(sql, parameters)
10601066
except sqlite3.Error as exc:
10611067
msg = str(exc)
10621068
try:

0 commit comments

Comments
 (0)