Skip to content

fix: open MongoDB clients after the Celery fork #659

Closed

Description

@uniqueg

Problem

Celery prefork children use a MongoClient opened in the parent, because create_celery_app() registers MongoDB before the fork. PyMongo warns MongoClient opened before fork, as a client used across a fork can hang.

Found during the review of #658: the reviewer reproduced the warning in a real worker run. A ForkPoolWorker also logged a warning in the chart log of that PR, but the log cut off before its text, so that instance isn't confirmed to be the same one.

Expected

Worker children open their own client after the fork (e.g., on worker_process_init), or the client isn't opened before the fork. No warning from PyMongo in a worker.

Impact to check

Apps with Celery workers that use MongoDB in tasks, such as proTES, may see tasks hang. Whether this happens in practice has not been checked.

Activity

  1. added this to the v0.21.0 milestone on Nov 4, 2026
  2. added
    priority: high
    status: triage
    type: bug
    workload: hours
    status: in progress
    and removed
    status: triage
    on Nov 4, 2026
  3. removed
    status: in progress
    on Nov 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    priority: hightype: bugworkload: hours

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions