How do I use trace to generate coverage data in multi-threaded programs?

Gabriel Genellina gagsl-py2 at yahoo.com.ar
Thu Dec 20 00:41:35 EST 2007


En Thu, 20 Dec 2007 00:33:00 -0300, Noah <noah at noah.org> escribió:

> I'm trying to use the trace module to build coverage files for
> a multi-threaded program.
>
>     http://docs.python.org/lib/module-trace.html
>
> I test my application using trace.py from the command-line like this:
>
>     /usr/lib/python2.5/trace.py --missing --count --summary tools/
> testall.py
>
> When I examine the *.cover files that are generated after a test run
> I do not see coverage information for the methods that were run
> in a separate thread. How can I collect coverage information for
> methods that only run in a separate thread (never in the main thread)?

There is a threading.settrace function, which sets the trace function for  
every thread just before it is started. I don't know if the trace module  
allows for multiple threads, or will just crash :), but in any case if one  
were to add support for this scenario, that would be the starting point.

-- 
Gabriel Genellina




More information about the Python-list mailing list