summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGES.rst4
-rw-r--r--coverage/backward.py6
-rw-r--r--coverage/sqldata.py11
3 files changed, 12 insertions, 9 deletions
diff --git a/CHANGES.rst b/CHANGES.rst
index 724a4545..547e346c 100644
--- a/CHANGES.rst
+++ b/CHANGES.rst
@@ -23,12 +23,16 @@ Unreleased
that missing branches are reported near the other lines they affect. The
values used to show all missing lines, and then all missing branches.
+- Access to the SQLite database used for data storage is now thread-safe.
+ Thanks, Stephan Richter. This closes `issue 702`_.
+
- Combining data stored in SQLite now goes about twice as fast, fixing `issue
761`_. Thanks, Stephan Richter.
- Line numbers in the HTML report now align properly with source lines, even
when Chrome's minimum font size is set, fixing `issue 748`_. Thanks Wen Ye.
+.. _issue 702: https://github.com/nedbat/coveragepy/issues/702
.. _issue 746: https://github.com/nedbat/coveragepy/issues/746
.. _issue 748: https://github.com/nedbat/coveragepy/issues/748
.. _issue 761: https://github.com/nedbat/coveragepy/issues/761
diff --git a/coverage/backward.py b/coverage/backward.py
index b43e35f3..2d0494a7 100644
--- a/coverage/backward.py
+++ b/coverage/backward.py
@@ -44,6 +44,12 @@ try:
except NameError:
range = range
+# Where do we get the thread id from?
+try:
+ from thread import get_ident as get_thread_id
+except ImportError:
+ from threading import get_ident as get_thread_id
+
# shlex.quote is new, but there's an undocumented implementation in "pipes",
# who knew!?
try:
diff --git a/coverage/sqldata.py b/coverage/sqldata.py
index b44556a5..09d647e5 100644
--- a/coverage/sqldata.py
+++ b/coverage/sqldata.py
@@ -17,18 +17,12 @@ import os
import sqlite3
import sys
-from coverage import env
-from coverage.backward import iitems
+from coverage.backward import get_thread_id, iitems
from coverage.data import filename_suffix
from coverage.debug import NoDebugging, SimpleReprMixin
from coverage.files import PathAliases
from coverage.misc import CoverageException, file_be_gone
-if env.PY2:
- from thread import get_ident as get_thread_id
-else:
- from threading import get_ident as get_thread_id
-
# Schema versions:
# 1: Released in 5.0a2
@@ -168,8 +162,7 @@ class CoverageSqliteData(SimpleReprMixin):
return self._dbs[get_thread_id()]
def __nonzero__(self):
- if (get_thread_id() not in self._dbs and
- not os.path.exists(self.filename)):
+ if (get_thread_id() not in self._dbs and not os.path.exists(self.filename)):
return False
try:
with self._connect() as con: