question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

tests with `multiprocessing` hang on Python 3.8 on macOS

See original GitHub issue

I’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:closed
  • Created 3 years ago
  • Comments:16 (16 by maintainers)

github_iconTop GitHub Comments

1reaction
andyfaffcommented, Apr 12, 2020

@peterbell10, you’re correct. Just tested out on local machine.

  • just the presence of import multiprocessing is enough to prevent hanging (freeze_support not required).
  • the tests don’t hang if there’s no import of multiprocessing and runtests.py uses parallelisation, I used -j 4.

It’s a bit crufty that just the presence of the import is enough…

1reaction
peterbell10commented, Apr 12, 2020

Pure speculation, but is it possible that adding import multiprocessing to runtests.py was what made the difference? It might change how the python module is initialised on the spawned process.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found