473,386 Members | 1,908 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

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

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?

--
Noah Spurrier
Dec 20 '07 #1
2 1240
En Thu, 20 Dec 2007 00:33:00 -0300, Noah <no**@noah.orgescribió:
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

Dec 20 '07 #2
On Dec 19, 7:33 pm, Noah <n...@noah.orgwrote:
/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.

--
Noah Spurrier
Dec 21 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Vijay Sankar | last post by:
Hi, I am using coverage.py to check the code coverage for some of my Python scripts. For a particular script which uses 'exit' calls, I am getting the following error when I invoke the script...
1
by: Daylor | last post by:
hi. i have application with 5 threads. can i use the trace and tracelistener, so if i trace in thread1 , it will write to file1, and if i trace to thread2 if will write to file2. hope im...
0
by: momina_dar | last post by:
AlachiSoft “TierDeveloper” eradicates the problem of writing thousands of lines of code for your middle tier. Many software solutions on the market can do it for you but according to our research...
0
by: djaquay | last post by:
I've been using trace.py to get code coverage results for my unit tests, and like it. Now I'm trying to use it for code coverage of the GUI parts of my wxPython-based program, and I realized how...
232
by: robert maas, see http://tinyurl.com/uh3t | last post by:
I'm working on examples of programming in several languages, all (except PHP) running under CGI so that I can show both the source files and the actually running of the examples online. The first...
2
by: Orin | last post by:
Hi, I have a problem in using coverage.py module in my project: ../cov -c Traceback (most recent call last): File "./cov", line 10, in ? coverage.the_coverage.command_line(sys.argv) File...
1
by: | last post by:
I have a multi threaded app that runs fine 99 percent of the time. However, sporadically, I receive error {Cannot evaluate expression because the current thread is in a stack overflow state.} at...
1
by: ofirmgr | last post by:
im trying to understand how the profiler works. so i started 2 profilers,one listen to another and I saw the profiler is running: exec sp_trace_create @P1 output, 1, NULL, NULL, NULL which means...
1
by: skip | last post by:
I am trying to use the trace module with the --count flag to test for statement coverage in my doctests. The trace coverage listing is very weird, marking many statements as unexecuted which were...
0
by: gray d newbie | last post by:
Hi All, I am currently supporting an ASP based system which is using Commerce Server 2000. On and off when the end user using the module, as long as the module have to do with user profile...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.