Repository navigation
Conversation
A pool worker tells the parent which worker it is by sending inqW_fd in READY and synqW_fd in ACK. Celery keys its worker lookups and its busy set by those numbers, and with synack it writes the ack to the reported synqW_fd, so they have to be the parent's numbers. The child worked them out from its own fd table. Under fork and POSIX spawn that gives the parent's numbers, but a forkserver child receives its pipes over a socket and can see them under different numbers. The parent then cannot find the worker that sent the message, so Celery leaves it marked busy and stops sending it tasks. Send the parent's numbers along with the worker in Worker.__reduce__, so the child reports those instead. The child only uses them as labels, never to read or write a pipe. The message format and Worker.__init__ are unchanged, and fork and spawn report the same values as before. Part of celery/celery#11096
This was referenced Nov 28, 2026
tzifudzi
marked this pull request as ready for review
November 28, 2026 22:35
Author
|
@auvipy regarding enhancement celery/celery#11096, ready with PRs now, please review. Separated PRs into separate granular changes to make them easier to review. |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Celery doesn't offer
forkserveryet, even though billiard supports it. It can't be enabled safely today, because the parent loses track of which workers are free.A worker identifies itself to the parent by the fd numbers of its pipes. Under
forkandspawnthose match the parent's numbers, but underforkserverthe pipes arrive over a socket and can get different numbers in the child. The parent then can't match the message to a worker, so Celery leaves that worker marked busy and stops sending it tasks.Fix
Worker.__reduce__now sends the parent'sinqW_fdandsynqW_fdalong with the worker, so the child reports those instead of its own, which allows the parent to more reliably identify the worker and mark it free when its task finishes.Related PRs
Restart the fork server if it dies celery/billiard #484
Replace the fork server on pool restart celery/billiard #485
Support forkserver as a prefork start method celery/celery #11177
Support preloading modules in the fork server celery/celery #11178