Skip to content

Commit

Permalink
A little clean-up from pr #760
Browse files Browse the repository at this point in the history
  • Loading branch information
nedbat committed Apr 9, 2019
1 parent cd15bc3 commit 10018dd
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
4 changes: 4 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions coverage/backward.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,12 @@
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:
Expand Down
11 changes: 2 additions & 9 deletions coverage/sqldata.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,12 @@
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
Expand Down Expand Up @@ -168,8 +162,7 @@ def _connect(self):
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:
Expand Down

0 comments on commit 10018dd

Please sign in to comment.