Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

--branch and --concurrency are conflicting #495

Closed
nedbat opened this issue Jun 1, 2016 · 3 comments
Closed

--branch and --concurrency are conflicting #495

nedbat opened this issue Jun 1, 2016 · 3 comments
Labels
bug Something isn't working combine

Comments

@nedbat
Copy link
Owner

nedbat commented Jun 1, 2016

Originally reported by Gabriel Duman (Bitbucket: gabber7, GitHub: gabber7)


i'm not sure if these two feature are meant to be combined.

this is a test script to reproduce

#!python

import multiprocessing
import sys


def func(value):
    if value % 2 == 0:
        print value, 'is even'
    else:
        print value, 'is odd'


if __name__ == "__main__":  # pragma: no cover
    values = range(2)
    pool = multiprocessing.Pool(processes=2)
    pool.map(func, values)
    pool.close()
    pool.join()

and here is the result

#!bash

> coverage --version
Coverage.py, version 4.1 with C extension
Documentation at https://coverage.readthedocs.io
> coverage run --branch --concurrency=multiprocessing test.py
0 is even
1 is odd
> coverage combine
Can't combine line data with arc data
> coverage report
Name      Stmts   Miss Branch BrPart  Cover
-------------------------------------------
test.py       6      3      2      0    38%
>

when i remove the argument --branch the combine command works. sometimes i get a warning that no data was collected. i cannot reproduce this at the moment.

#!bash

> coverage run --concurrency=multiprocessing test.py
0 is even
1 is odd
Coverage.py warning: No data was collected.
> coverage combine
> coverage report
Name      Stmts   Miss  Cover
-----------------------------
test.py       6      0   100%
>

@nedbat
Copy link
Owner Author

nedbat commented Jun 24, 2016

@gabber7 Thanks for the report. You can work around this limitation by putting "[run] branch=True" into a .coveragerc file.

@nedbat
Copy link
Owner Author

nedbat commented Jul 4, 2016

I'm going to leave this as a documented limitation of the command-line flags. Once programs get complicated enough to use multiprocessing, options should go in a configuration file.

@nedbat
Copy link
Owner Author

nedbat commented Jul 9, 2016

As of eb8d32874d54 (bb), command lines that mix options like this will fail with an error message.

@nedbat nedbat closed this as completed Jul 9, 2016
@nedbat nedbat added major bug Something isn't working combine labels Jun 23, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working combine
Projects
None yet
Development

No branches or pull requests

1 participant