summaryrefslogtreecommitdiff
path: root/coverage/collector.py
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2013-03-10 10:34:06 -0400
committerNed Batchelder <ned@nedbatchelder.com>2013-03-10 10:34:06 -0400
commita76468c859f4a1a2a60d81863ff14b31bc87eaad (patch)
tree73a2776cc35d729afff9ca2c326d071c845e347a /coverage/collector.py
parent41b2f5bb231ce32f1f3c9a5f9bdbe573fcf964eb (diff)
parentd05b0617fad4d7972c6b8a1c671b4a00c37f1208 (diff)
downloadpython-coveragepy-git-a76468c859f4a1a2a60d81863ff14b31bc87eaad.tar.gz
Automated merge with ssh://bitbucket.org/ned/coveragepy
Diffstat (limited to 'coverage/collector.py')
-rw-r--r--coverage/collector.py10
1 files changed, 7 insertions, 3 deletions
diff --git a/coverage/collector.py b/coverage/collector.py
index 0cfd8fff..781a0fa6 100644
--- a/coverage/collector.py
+++ b/coverage/collector.py
@@ -51,6 +51,7 @@ class PyTracer(object):
self.last_exc_back = None
self.last_exc_firstlineno = 0
self.arcs = False
+ self.thread = None
def _trace(self, frame, event, arg_unused):
"""The trace function passed to sys.settrace."""
@@ -118,18 +119,21 @@ class PyTracer(object):
Return a Python function suitable for use with sys.settrace().
"""
+ self.thread = threading.currentThread()
sys.settrace(self._trace)
return self._trace
def stop(self):
"""Stop this Tracer."""
+ if self.thread != threading.currentThread():
+ # Called on a different thread than started us: do nothing.
+ return
+
if hasattr(sys, "gettrace") and self.warn:
if sys.gettrace() != self._trace:
msg = "Trace function changed, measurement is likely wrong: %r"
self.warn(msg % (sys.gettrace(),))
- #--debug
- #from coverage.misc import short_stack
- #self.warn(msg % (sys.gettrace()))#, short_stack()))
+ #print("Stopping tracer on %s" % threading.current_thread().ident)
sys.settrace(None)
def get_stats(self):