diff options
Diffstat (limited to 'coverage/collector.py')
-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: |