-
-
Notifications
You must be signed in to change notification settings - Fork 436
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
coverage run and multiprocessing problem #745
Comments
I tried to reproduce this, but don't see the failure. Can you provide exact files to run, and the precise versions of nose and coverage? Thanks. |
Thanks @nedbat, Sorry for missing required information. Attached 2 files: my_pool.py and test_my_pool.py. please download the files to 'src' folder and within 'src' run: This should reproduce the problem. Thanks, |
Hmm, I tried this in a Windows VM, and the "py -3 -m nose test_my_pool.py" command hung for a while, doing nothing? |
I am experiencing the same issue but with It appears to work on the linux CI servers though so I'm not sure if it's platform specific or related to the environment.
|
I am seeing the same as OP with python 3.6.8 nose 1.3.7 and coverage 4.4.1, on linux when multiprocessing method is spawn or forkserver (not fork). here is my repro: test_me.py
.coveragerc
command:
|
Add test which triggers the problem.
I hit this problem myself and have got part of the way to understanding what is happening, but there is more going on that I don't understand. Please see the above pull request for details. |
Same problem here. Simple way to reproduce it:
Works fine with unittest:
When running in coverage:
I tested both with and without "concurrency = multiprocessing" in .coveragerc |
I'm seeing this on Mac, and it looks like ali1234 was using Linux. Can we get the 'Windows' label removed? This appeared for me when changing from a Python 3.7 venv to a Python 3.8 one. I can work-around by using |
Spawn was made the default start method for MacOS in 3.8 so this also points to that being the cause. (It has always been the default on Windows as it doesn't have Spawn requires multiprocessing to pickle functions and send them to the subprocesses to run. Pickling a function just sends the canonical name - that name must exist/be importable in the subprocess. |
Thanks everyone for the information. I'm hoping to dig into this soon. Of course, if anyone wants to debug it, I'm ready for clues :) |
I tried to fix this in https://github.com/nedbat/coveragepy/pull/836/files. This fixed the exception but I think it broke all coverage checking in subprocesses. The ModuleSpec was certainly something to do with it. (I later gave up with this because I found that spawn was not a suitable solution for my application due to re-importing all modules taking too long; I changed to run a new interpreter manually using the subprocess module.) |
This is fixed in 47d1659. |
This was released as part of 5.0b2 today. |
Hi,
I'm facing some issue with coverage and multiprocessing module.
I have a simple class wrapping multiprocessing.Pool:
matlab_interop/my_pool.py:
and a simple unittest:
tests/test_my_pool.py
when running:
coverage halts and I get errors that I don't get if running nose directly without coverage.
I would appreciate your help with figuring out what could be the problem. I don't understand why all works when running nose directly (without coverage).
Thanks.
The text was updated successfully, but these errors were encountered: