Skip to content

Deserialize all tasks in a chain#4015

Merged
auvipy merged 1 commit intocelery:masterfrom
fcoelho:chain-from-dict
Jun 2, 2017
Merged

Deserialize all tasks in a chain#4015
auvipy merged 1 commit intocelery:masterfrom
fcoelho:chain-from-dict

Conversation

@fcoelho
Copy link
Contributor

@fcoelho fcoelho commented May 4, 2017

When loading a chain that had been fully serialized to json, deserialization
happened only in part of the original task. Specifically, take a
json-serialized task that looks like the following:

{
    ...,
    "kwargs": {
        "tasks": [
            {...}, {...}, {...}
        ]
    }
}

After calling celery.signature(that_thing_above), we get an object that
actually looks like this:

{
    ...,
    "kwargs": {
        "tasks": [
            task_1, # an instance of celery.Signature
            {...}, {...} # same as before deserialization
        ]
    }
}

The culprit was chain.from_dict, which was converting only the first subtask
of the chain to actual Signature instances. This commit changes that
behaviour and converts all subtasks to signatures instead. Without this, some
operations on the chain object, such as calling chain.on_error(...) would
cause errors of the form 'dict' object has no attribute 'xyz'.

When loading a chain that had been fully serialized to json, deserialization
happened only in part of the original task. Specifically, take a
json-serialized task that looks like the following:

    {
        ...,
        "kwargs": {
            "tasks": [
                {...}, {...}, {...}
            ]
        }
    }

After calling `celery.signature(that_thing_above)`, we get an object that
actually looks like this:

    {
        ...,
        "kwargs": {
            "tasks": [
                task_1, # an instance of celery.Signature
                {...}, {...} # same as before deserialization
            ]
        }
    }

The culprit was `chain.from_dict`, which was converting only the first subtask
of the chain to actual `Signature` instances. This commit changes that
behaviour and converts all subtasks to signatures instead. Without this, some
operations on the chain object, such as calling `chain.on_error(...)` would
cause errors of the form `'dict' object has no attribute 'xyz'`.
@auvipy auvipy self-assigned this Jun 2, 2017
@auvipy auvipy merged commit 1735336 into celery:master Jun 2, 2017
SebastianBerchtold pushed a commit to smartlane/celery that referenced this pull request Jun 11, 2018
When loading a chain that had been fully serialized to json, deserialization
happened only in part of the original task. Specifically, take a
json-serialized task that looks like the following:

    {
        ...,
        "kwargs": {
            "tasks": [
                {...}, {...}, {...}
            ]
        }
    }

After calling `celery.signature(that_thing_above)`, we get an object that
actually looks like this:

    {
        ...,
        "kwargs": {
            "tasks": [
                task_1, # an instance of celery.Signature
                {...}, {...} # same as before deserialization
            ]
        }
    }

The culprit was `chain.from_dict`, which was converting only the first subtask
of the chain to actual `Signature` instances. This commit changes that
behaviour and converts all subtasks to signatures instead. Without this, some
operations on the chain object, such as calling `chain.on_error(...)` would
cause errors of the form `'dict' object has no attribute 'xyz'`.
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.

2 participants