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

Discussion in 'Python' started by Noah, Dec 20, 2007.

  1. Noah

    Noah Guest

    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
     
    Noah, Dec 20, 2007
    #1
    1. Advertising

  2. En Thu, 20 Dec 2007 00:33:00 -0300, Noah <> 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
     
    Gabriel Genellina, Dec 20, 2007
    #2
    1. Advertising

  3. Noah

    Noah Guest

    On Dec 19, 7:33 pm, Noah <> wrote:
    > /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
     
    Noah, Dec 21, 2007
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Rukmal Fernando
    Replies:
    4
    Views:
    862
    Richard Grimes [MVP]
    Oct 27, 2003
  2. Matthias S.
    Replies:
    1
    Views:
    666
    Daniel Fisher\(lennybacon\)
    Nov 30, 2005
  3. Raj
    Replies:
    4
    Views:
    7,795
    asicvlsi
    Feb 21, 2008
  4. Ben Finney
    Replies:
    7
    Views:
    544
    Ned Batchelder
    Oct 30, 2007
  5. Replies:
    0
    Views:
    389
Loading...

Share This Page