diff options
| author | Olivier Grisel <olivier.grisel@ensta.org> | 2017-08-10 15:52:35 +0200 | 
|---|---|---|
| committer | Olivier Grisel <olivier.grisel@ensta.org> | 2017-08-10 15:52:35 +0200 | 
| commit | bfee14ab8788b6c97f58308ec5c5b14e57d06cb7 (patch) | |
| tree | 411decc23e74c8c2534ac34e588b80f1980920cd /coverage/ctracer | |
| parent | 3bb0bcaeaaa429bd63cce00ef0459f1ba8436c00 (diff) | |
| download | python-coveragepy-git-bfee14ab8788b6c97f58308ec5c5b14e57d06cb7.tar.gz | |
FIX thread-safe Collector.save_data()
--HG--
branch : fix-thread-safety
Diffstat (limited to 'coverage/ctracer')
| -rw-r--r-- | coverage/ctracer/tracer.c | 8 | 
1 files changed, 8 insertions, 0 deletions
diff --git a/coverage/ctracer/tracer.c b/coverage/ctracer/tracer.c index 625a45a6..236fbbfa 100644 --- a/coverage/ctracer/tracer.c +++ b/coverage/ctracer/tracer.c @@ -833,6 +833,14 @@ CTracer_trace(CTracer *self, PyFrameObject *frame, int what, PyObject *arg_unuse      return RET_OK;      #endif +    if (!self->started) { +        /* If CTracer.stop() has been called from another thread, the tracer +           is still active in the current thread. Let's deactivate ourselves +           now. */ +        PyEval_SetTrace(NULL, NULL); +        return RET_OK; +    } +      #if WHAT_LOG || TRACE_LOG      PyObject * ascii = NULL;      #endif  | 
