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

N

Noah

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)?

Any tips?
 
G

Gabriel Genellina

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.
 
N

Noah

/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)?

Just for the record, the problem was due to the fact that I was
creating threads
using the "thread" module. When I switched to creating threads using
the
"threading" module I was able to see my thread code in coverage
reports.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,818
Latest member
Brigette36

Latest Threads

Top