[TIP] coverage and multiprocessing

Ned Batchelder ned at nedbatchelder.com
Wed Sep 7 09:26:36 PDT 2016


If you could provide a reproducible scenario, I can dig into what's
going on.

--Ned.


On 9/7/16 9:49 AM, Chris Withers wrote:
>
> Hi Ned,
>
> I hope so!
>
> The core of my mp code is:
>
> pool = Pool(processes=processes, initializer=init)
> result = pool.imap_unordered(func, iterable)
> started = datetime.now()
> try:
>     if progress:
>         i = show_progress(started, result)
>     else:
>         for i, _ in enumerate(result): pass finally:
>     pool.terminate()
>     pool.join()
> Does that look write/wrong?
>
> Chris
>
> On 07/09/2016 11:09, Ned Batchelder wrote:
>> Chris,
>>
>> Do your workers exit cleanly?
>>
>> --Ned.
>>
>>
>> On 9/6/16 5:19 PM, Chris Withers wrote:
>>> Hi All,
>>>
>>> I run my tests like this:
>>>
>>> coverage run --concurrency=multiprocessing --source myproject,tests -m
>>> nose && coverage report --skip-covered --show-missing
>>>
>>> Some of the code is only reached by being called by some
>>> multiprocessing.Pool workers, the pool being instantiated and fed by
>>> one of the functions under test.
>>>
>>> After running the above, I see:
>>>
>>> $ ls -lah .coverage*
>>> -rw-r--r--+ 1 chris  staff    25K  6 Sep 19:31 .coverage
>>> -rw-r--r--+ 1 chris  staff     0B  6 Sep 19:30
>>> .coverage.tweedledee.26019.082222
>>> -rw-r--r--+ 1 chris  staff     0B  6 Sep 19:30
>>> .coverage.tweedledee.26020.787224
>>> -rw-r--r--+ 1 chris  staff     0B  6 Sep 19:30
>>> .coverage.tweedledee.26021.467684
>>> -rw-r--r--+ 1 chris  staff     0B  6 Sep 19:30
>>> .coverage.tweedledee.26022.663538
>>>
>>> So, it looks like coverage is trying to record information in the
>>> worker processes by failing. What might be the issue and how can I fix
>>> it?
>>>
>>> cheers,
>>>
>>> Chris
>>>
>>>
>>> _______________________________________________
>>> testing-in-python mailing list
>>> testing-in-python at lists.idyll.org
>>> http://lists.idyll.org/listinfo/testing-in-python
>> _______________________________________________
>> 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/20160907/4e2ffbe3/attachment.htm>


More information about the testing-in-python mailing list