Skip to content

Strange behavior with ProcessPoolExecutor #1038

Open
@0x0L

Description

@0x0L

Hello,

I don't have simple reproducible example but the same tox suite running pytest --cov --cov-append reports slightly differently in py37 and py38.

I set up my .coveragerc as follows

[path]
source =
    src
    */site-packages
    *\site-packages

[run]
branch = true
parallel = true
source =
    my_package
    tests

Running in py37 correctly report the code under src/my_package and tests
In py38, i see additional lines .tox/py38/.../site-packages/my_package/*.py. The only hits for those files are actually callback code called in a ProcessPoolExecutor

I tried setting concurrency = multiprocessing but it didn't help.

As a workaround, I'm omitting these files when reporting but it's still puzzling as it only happens with 3.8 :)

Activity

added
bugSomething isn't working
on Oct 7, 2020
nedbat

nedbat commented on Oct 11, 2020

@nedbat
Owner

It's hard to know what's going on without being able to reproduce it myself, but here are some thoughts:

  • Are you sure your package is installed in site-packages in both 3.7 and 3.8?
  • Can you run coverage with --debug=trace? That will show what files are being considered for measurement.
0x0L

0x0L commented on Oct 13, 2020

@0x0L
Author

Hi,

Thanks for getting back to me.
I setup a repo at https://github.com/0x0L/testcov
I'm able to reproduce it locally on my machine

tox 3.20.1

---------- coverage: platform darwin, python 3.7.9-final-0 -----------
Name                    Stmts   Miss Branch BrPart     Cover   Missing
----------------------------------------------------------------------
src/gruik/__init__.py       6      0      0      0   100.00%
tests/test_a.py             3      0      0      0   100.00%
----------------------------------------------------------------------
TOTAL                       9      0      0      0   100.00%
---------- coverage: platform darwin, python 3.8.3-final-0 -----------
Name                                                      Stmts   Miss Branch BrPart     Cover   Missing
--------------------------------------------------------------------------------------------------------
.tox/py38/lib/python3.8/site-packages/gruik/__init__.py       6      2      0      0    66.67%   9-10
src/gruik/__init__.py                                         6      0      0      0   100.00%
tests/test_a.py                                               3      0      0      0   100.00%
--------------------------------------------------------------------------------------------------------
TOTAL                                                        15      2      0      0    86.67%
nedbat

nedbat commented on Oct 13, 2020

@nedbat
Owner

Hmm, I can reproduce the behavior, but I don't understand why it would be different for the two versions. It might have to do with how multiprocessing is implemented?

0x0L

0x0L commented on Oct 14, 2020

@0x0L
Author

It definitely looks like it but I see no mention of any change to the ProcessPool in the release notes for 3.8

0x0L

0x0L commented on Jan 28, 2021

@0x0L
Author

@nedbat
Actually the issue is not python 3.8 specific. In the example repo https://github.com/0x0L/testcov I added py39 and changed the order of the envlist.

With envlist = clean,py39,py37,py38,report, I get

---------- coverage: platform darwin, python 3.9.1-final-0 -----------
Name                    Stmts   Miss Branch BrPart     Cover   Missing
----------------------------------------------------------------------
src/gruik/__init__.py       6      0      0      0   100.00%
tests/test_a.py             3      0      0      0   100.00%
----------------------------------------------------------------------
TOTAL                       9      0      0      0   100.00%

---------- coverage: platform darwin, python 3.7.9-final-0 -----------
Name                                                      Stmts   Miss Branch BrPart     Cover   Missing
--------------------------------------------------------------------------------------------------------
.tox/py37/lib/python3.7/site-packages/gruik/__init__.py       6      5      0      0    16.67%   1-4, 8-10
src/gruik/__init__.py                                         6      0      0      0   100.00%
tests/test_a.py                                               3      0      0      0   100.00%
--------------------------------------------------------------------------------------------------------
TOTAL                                                        15      5      0      0    66.67%

---------- coverage: platform darwin, python 3.8.5-final-0 -----------
Name                                                      Stmts   Miss Branch BrPart     Cover   Missing
--------------------------------------------------------------------------------------------------------
.tox/py37/lib/python3.7/site-packages/gruik/__init__.py       6      5      0      0    16.67%   1-4, 8-10
.tox/py38/lib/python3.8/site-packages/gruik/__init__.py       6      2      0      0    66.67%   9-10
src/gruik/__init__.py                                         6      0      0      0   100.00%
tests/test_a.py                                               3      0      0      0   100.00%
--------------------------------------------------------------------------------------------------------
TOTAL                                                        21      7      0      0    66.67%
changed the title [-]ProcessPoolExecutor in py38[/-] [+]Strange behavior with ProcessPoolExecutor[/+] on Feb 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @nedbat@0x0L

        Issue actions

          Strange behavior with ProcessPoolExecutor · Issue #1038 · nedbat/coveragepy