Skip to content
New issue

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

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

Already on GitHub? # to your account

Set multiprocessing start method explicitly through context #447

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

nvictus
Copy link
Member

@nvictus nvictus commented Dec 19, 2024

The default start method for multiprocessing will change from "fork" to "spawn" on all platforms: https://docs.python.org/3/library/multiprocessing.html#contexts-and-start-methods

This PR uses contexts to keep the current fork behavior until we decide to migrate to spawn or refactor further. cc @mimakaev

@nvictus
Copy link
Member Author

nvictus commented Dec 19, 2024

Well, this obviously fails on Windows, which can't fork...

@nvictus nvictus requested a review from mimakaev December 20, 2024 23:55
@nvictus
Copy link
Member Author

nvictus commented Dec 21, 2024

I implemented accessors for the reusable global multiprocessing state used by the cooler CLI. They are initialized on first access. It creates a context with "fork" on Unix/MacOS and "spawn" in Windows, but the method can be overridden with an environment variable COOLER_DEFAULT_MP_METHOD.

This has the benefit that multiprocessing objects won't be constructed if only the cooler API is used, as in #329 where multiprocessing synchronization primitives are not available on AWS lambda. cc @pkerpedjiev

@nvictus nvictus requested a review from pkerpedjiev December 21, 2024 00:45
@nvictus nvictus changed the title Set multiprocessing fork method explicitly through context Set multiprocessing start method explicitly through context Dec 21, 2024
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant