-
Notifications
You must be signed in to change notification settings - Fork 128
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add before suite hook to set mp start method.
The default multiprocessing start method is "fork" which is not compatible with with runtime assertions that it is set to spawn. When running unit tests, it's possible to call an external library that sets the start method to "fork". Here we enforce the start method to be "spawn" for all tests before executing.
- Loading branch information
Showing
2 changed files
with
14 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import multiprocessing | ||
import pytest | ||
|
||
|
||
# The default multiprocessing start method is "fork" which is not compatible with | ||
# with runtime assertions that it is set to spawn. When running unit tests, it's | ||
# possible to call an external library that sets the start method to "fork". | ||
# Here we enforce the start method to be "spawn" for all tests before executing. | ||
@pytest.fixture(scope="session", autouse=True) | ||
def initialize_data_environment(): | ||
try: | ||
multiprocessing.set_start_method("spawn") | ||
except Exception: | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters