tests with `multiprocessing` hang on Python 3.8 on macOS
See original GitHub issueI’m running the whole test suite on macOS on Python 3.8 (via Github Actions on my local machine (Catalina)). I’m seeing several issues with multiprocessing, such as #11827.
They’re related to https://bugs.python.org/issue38501. The tests that hang are:
I think the best thing to do at the moment is to use the skipif decorator (possibly also coupled to Darwin):
@pytest.mark.skipif(multiprocessing.get_start_method() != 'fork',
reason=('multiprocessing with spawn method is not'
' compatible with pytest.'))
Issue Analytics
- State:
- Created 3 years ago
- Comments:16 (16 by maintainers)
Top Results From Across the Web
Multiprocessing spawn (default on macOS since Python 3.8) is ...
I am being fairly vague here, but it is mainly because I don't know the best way to reduce the test cases down...
Read more >How to Use Django's Parallel Testing on macOS With Python ...
The second step is to add a call to multiprocessing.set_start_method() at the top of main() in your manage.py file. This is best accompanied ......
Read more >Multiprocessing in python3 get different values when running ...
I am seeing the former output (the one you see on Linux) on macOS 10.15 with Python 3.6.5, and it turns out that...
Read more >Multiprocessing Changes in Python 3.8 - Christopher Sardegna
One of those additions to make Python a safer language altered how processes are created when running on MacOS. These changes deeply affect...
Read more >Why your multiprocessing Pool is stuck (it's full of sharks!)
Here's where it gets interesting: fork() -only is how Python creates process pools by default on Linux, and on macOS on Python 3.7...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@peterbell10, you’re correct. Just tested out on local machine.
import multiprocessing
is enough to prevent hanging (freeze_support not required).-j 4
.It’s a bit crufty that just the presence of the import is enough…
Pure speculation, but is it possible that adding
import multiprocessing
toruntests.py
was what made the difference? It might change how the python module is initialised on the spawned process.