[TIP] coverage.py and os.fork()?

Ned Batchelder ned at nedbatchelder.com
Mon Mar 15 03:45:41 PDT 2010


Joe, I read your first email last night, and mulling over the 
possibilities, concluded that the problem was just as you have 
diagnosed.  I awoke this morning ready to fix it, and found you already 
had!  I'll apply the patch today...

Thanks.

--Ned.

Joe Malicki wrote:
> I dug in enough to realize it seemed to be a fairly fatal flaw of how
> parallel=True was implemented.
>
> Issue and provisional patch that seem to work for me here:
>
> http://bitbucket.org/ned/coveragepy/issue/56/
>
> Thanks!
> Joe
>
> On Sun, Mar 14, 2010 at 7:38 PM, Joe Malicki <jmalicki at gmail.com> wrote:
>   
>> Does anyone have a recipe of getting coverage.py to work across a fork()?
>>
>> I was trying to use coverage 3.3.1 with python 2.6 and
>> multiprocessing, and couldn't figure out how to get it to trace the
>> child.
>> Attached is a simple test program to illustrate behavior and show
>> things I tried.
>>
>> Is there another way of doing this I didn't come across, or is this
>> something that needs to be hacked into coverage?
>>
>> Thanks!
>> Joe
>>
>> with coverage run -p testcover.py, i see:
>>
>> jmalicki at boott-spur:~$ coverage combine
>> jmalicki at boott-spur:~$ coverage report -m
>> Name        Stmts   Exec  Cover   Missing
>> -----------------------------------------
>> testcover      19     10    52%   10-20, 27
>>
>> When I explicitly call stop: coverage run -p testcover.py -t
>> Child!
>> Traceback (most recent call last):
>>  File "testcover.py", line 32, in <module>
>>    main(sys.argv)
>>  File "testcover.py", line 27, in main
>>    child(args)
>>  File "testcover.py", line 18, in child
>>    coverage.stop()
>>  File "/usr/local/lib/python2.6/dist-packages/coverage-3.3.1-py2.6-linux-x86_64.egg/coverage/__init__.py",
>> line 39, in wrapper
>>    return getattr(_the_coverage, name)(*args, **kwargs)
>>  File "/usr/local/lib/python2.6/dist-packages/coverage-3.3.1-py2.6-linux-x86_64.egg/coverage/control.py",
>> line 212, in stop
>>    self.collector.stop()
>>  File "/usr/local/lib/python2.6/dist-packages/coverage-3.3.1-py2.6-linux-x86_64.egg/coverage/collector.py",
>> line 214, in stop
>>    assert self._collectors[-1] is self
>> AssertionError
>>
>> coverage run -p testcover.py -s
>> Child!
>> jmalicki at boott-spur:~$ coverage combine
>> coverage report -m:
>> Name        Stmts   Exec  Cover   Missing
>> -----------------------------------------
>> testcover      19     10    52%   10-20, 27
>>
>>     
>
> _______________________________________________
> testing-in-python mailing list
> testing-in-python at lists.idyll.org
> http://lists.idyll.org/listinfo/testing-in-python
>   
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.idyll.org/pipermail/testing-in-python/attachments/20100315/f53ec5b1/attachment.html>


More information about the testing-in-python mailing list