summaryrefslogtreecommitdiff
path: root/coverage/sqldata.py
diff options
context:
space:
mode:
authorStephan Richter <stephan.richter@gmail.com>2019-01-24 17:38:22 -0500
committerNed Batchelder <ned@nedbatchelder.com>2019-06-10 17:15:32 -0400
commit772620925a8e8c173fd1131a80be0f9cc84a6cce (patch)
tree94d6e5c8f1d8346b2243d8303e317c6a54cc90cb /coverage/sqldata.py
parent368676b837045636141238ac295ac302e099611a (diff)
downloadpython-coveragepy-git-772620925a8e8c173fd1131a80be0f9cc84a6cce.tar.gz
Tricky case: Thread switching is getting in the way.
Diffstat (limited to 'coverage/sqldata.py')
-rw-r--r--coverage/sqldata.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/coverage/sqldata.py b/coverage/sqldata.py
index 9291bddd..fe32dcdc 100644
--- a/coverage/sqldata.py
+++ b/coverage/sqldata.py
@@ -662,7 +662,12 @@ class Sqlite(SimpleReprMixin):
# has non-ascii characters in it. Opening a relative file name avoids
# a problem if the current directory has non-ascii.
filename = os.path.relpath(self.filename)
- self.con = sqlite3.connect(filename)
+ # It can happen that Python switches threads while the tracer writes
+ # data. The second thread will also try to write to the data,
+ # effectively causing a nested context. However, given the indempotent
+ # nature of the tracer operations, sharing a conenction among threads
+ # is not a problem.
+ self.con = sqlite3.connect(filename, check_same_thread=False)
# This pragma makes writing faster. It disables rollbacks, but we never need them.
# PyPy needs the .close() calls here, or sqlite gets twisted up: