Skip to content

Support forkserver as a prefork start method - #11177

Open
tzifudzi wants to merge 1 commit into
celery:mainfrom
tzifudzi:forkserver-start-method
Open

tzifudzi wants to merge 1 commit into
celery:mainfrom
tzifudzi:forkserver-start-method

Conversation

@tzifudzi

@tzifudzi tzifudzi commented Nov 28, 2026 •

Copy link
Copy Markdown

Part of enhancement Support forkserver as a worker_pool_start_method celery/celery#11096.

Problem

Celery’s prefork pool offers fork and spawn but doesn’t offer forkserver. Billiard supports forkserver, and the forkserver mode became the default multiprocessing start method on Linux in Python 3.14, released October 7, 2025.

forkserver matters for use cases where forking from a process other than the parent is desirable. For example, when pool children need to avoid inheriting fork-unsafe state, such as gRPC clients initialized by the main worker, forkserver forks them from a separate server process.

Solution

Add forkserver as an opt-in start method for Celery’s prefork pool on Linux and macOS. Users can select it in their configuration or on the command line.

Configuration (celeryconfig.py)

worker_pool_start_method = "forkserver"

CLI

celery -A myapp worker --pool-start-method=forkserver

Related PRs

Report the parent's fd numbers from forkserver pool workers celery/billiard #483
Restart the fork server if it dies celery/billiard #484
Replace the fork server on pool restart celery/billiard #485
Support preloading modules in the fork server celery/celery #11178

Expose forkserver through the worker setting and CLI on Linux and macOS. Leave application preloading disabled and cover task dispatch after the pool has used all its children.

Part of celery#11096.
@tzifudzi

Copy link
Copy Markdown
Author

@auvipy regarding enhancement #11096, ready with PRs now, please review. Separated PRs into separate granular changes to make them easier to review.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant