Skip to content

Celery can not select start_method of multiprocessing #5021

Closed

Description

@DonYum

Checklist

  • I have included the output of celery -A proj report in the issue.

    software -> celery:4.2.1 (windowlicker) kombu:4.2.1 py:3.6.4
                billiard:3.5.0.4 redis:2.10.6
    platform -> system:Linux arch:64bit imp:CPython
    loader   -> celery.loaders.app.AppLoader
    settings -> transport:redis results:redis://10.60.242.49:6379/12
    
    BROKER_URL: 'redis://10.60.242.49:6379/11'
    CELERY_RESULT_BACKEND: 'redis://10.60.242.49:6379/12'
    CELERY_TIMEZONE: 'Asia/Shanghai'
    CELERYD_CONCURRENCY: 5
    
  • I have verified that the issue exists against the master branch of Celery.

Steps to reproduce

Code is as below:

from random import random
from celery import Celery

app = Celery('MigrateCeph')
settings = dict(
    BROKER_URL='redis://10.60.242.49:6379/11',
    CELERY_RESULT_BACKEND='redis://10.60.242.49:6379/12',
    CELERY_TIMEZONE='Asia/Shanghai',
    CELERYD_CONCURRENCY=5,
app.config_from_object(settings)

rand_val = random()

@app.task
def add(x, y):
    print(f'[Test]: ====> id={id(rand_val)}, val={rand_val}.')
    return x + y

Expected behavior

Get 5 different 'random' value.

Actual behavior

I got 5 same 'random' value, and their ID is same too:

[2018-09-01 16:00:14,174: WARNING/ForkPoolWorker-3] [Test]: ====> id=139629697025152, val=0.45579480912770987.
[2018-09-01 16:00:14,174: WARNING/ForkPoolWorker-4] [Test]: ====> id=139629697025152, val=0.45579480912770987.
[2018-09-01 16:00:14,180: WARNING/ForkPoolWorker-2] [Test]: ====> id=139629697025152, val=0.45579480912770987.
[2018-09-01 16:00:14,180: WARNING/ForkPoolWorker-5] [Test]: ====> id=139629697025152, val=0.45579480912770987.
[2018-09-01 16:00:14,184: WARNING/ForkPoolWorker-3] [Test]: ====> id=139629697025152, val=0.45579480912770987.

My Endeavor

In multiprocessing, there are 3 start_method: spawn/fork/forkserver. Each one have its own feature.

Such as, I want every worker have seperated file descriptors and handles. So I can only use spawn or forkserver method, rather than fork.

Ref: https://docs.python.org/3.4/library/multiprocessing.html?highlight=process#contexts-and-start-methods

However, celery only have fork method.

And I have try to use mp.set_start_method() to set it manually.
Unfortunately, it failed too.

Then I found celery use billiard rather than mp. So I tried billiard again, also fail.

Thx for your attention!

Activity

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions