diff options
author | Ned Batchelder <ned@nedbatchelder.com> | 2013-09-16 21:24:36 -0400 |
---|---|---|
committer | Ned Batchelder <ned@nedbatchelder.com> | 2013-09-16 21:24:36 -0400 |
commit | d8e211e3ccfaa174d5aa86d88346052a5c802b9d (patch) | |
tree | 488d672a82427d71581772443d3716ec60aaa0e8 | |
parent | 5ab6e055652510139a52219f58e5c6f3d22c272e (diff) | |
parent | 5dce0bc12651b339f947c87b9a2f40ccce892416 (diff) | |
download | python-coveragepy-git-d8e211e3ccfaa174d5aa86d88346052a5c802b9d.tar.gz |
Automated merge with ssh://bitbucket.org/ned/coveragepy
-rw-r--r-- | coverage/collector.py | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/coverage/collector.py b/coverage/collector.py index 9a74700d..8ba7d87c 100644 --- a/coverage/collector.py +++ b/coverage/collector.py @@ -52,10 +52,14 @@ class PyTracer(object): self.last_exc_firstlineno = 0 self.arcs = False self.thread = None + self.stopped = False def _trace(self, frame, event, arg_unused): """The trace function passed to sys.settrace.""" + if self.stopped: + return + if 0: sys.stderr.write("trace event: %s %r @%d\n" % ( event, frame.f_code.co_filename, frame.f_lineno @@ -126,8 +130,11 @@ class PyTracer(object): def stop(self): """Stop this Tracer.""" + self.stopped = True if self.thread != threading.currentThread(): - # Called on a different thread than started us: do nothing. + # Called on a different thread than started us: we can't unhook + # ourseves, but we've set the flag that we should stop, so we won't + # do any more tracing. return if hasattr(sys, "gettrace") and self.warn: |