Skip to content

Chains with unregistered tasks fail to call callbacks (send_task bug) #1522

Closed

Description

@taylornelson

If we create a chain like so:

subtasks = [
app.task1.subtask(),
app.task2.subtask(),
app.task3.subtask(),
]

The third task will not be called. This is because publish_task is called in two different fashions.

Calls to publish_task:
celery/app/base.py: return result_cls(producer.publish_task(
celery/app/task.py: task_id = P.publish_task(self.name, args, kwargs,

In task.py, the call is correct, errbacks and callbacks are specified:
494: task_id = P.publish_task(self.name, args, kwargs,
495: task_id=task_id,
496: callbacks=maybe_list(link),
497: errbacks=maybe_list(link_error),
498: reply_to=reply_to or self.app.oid,
499: **options)

In base.py callbacks/errbacks are not set:
294: return result_cls(producer.publish_task(
295: name, args, kwargs,
296: task_id=task_id,
297: countdown=countdown, eta=eta,
298: expires=expires, **options
299: ))

A fix is to add callbacks=options.get('link'), on line 298 of the above.

Taylor Nelson
[email protected]

Activity

  1. natecode commented on Aug 27, 2013

    @natecode

    This is a serious issue. It means that the remainder of chains of length >= 3 subtasks fail to run. When fixing this, please also take a look at other areas where changes might not have been propagated correctly across the base.py/task.py split.

  2. ask commented on Aug 29, 2013

    @ask
    Contributor

    This is not what happens here, the length of the chain does not matter. What happens is that subtasks for tasks that are not registered falls back to using send_task, and send_task does not honor the link/link_error arguments properly.

    The fix is in master and 3.0 branches!

  3. ask commented on Aug 29, 2013

    @ask
    Contributor

    I will release 3.0.23 tomorrow with this fix in it (Friday is our release day)

    Also, I have been meaning to refactor the separate send_task/apply_async methods for some time now, it has often resulted in bugs but there are some challenges in merging them.

  4. natecode commented on Aug 29, 2013

    @natecode

    I see. We are using different classes of celery workers (say, windows and Linux). They don't register the same sets of tasks, but we run a chain that crosses worker types. That way a file can be processed in a pipeline across different hardware.

    One issue we had to work around was having to import our module just to call a task by reference. This meant we had to do dynamic imports when the called task depended on windows-only imports, for example.

    We could use send_task with "call by name", but it would be nice to have a "shallow import" function that pulls in @task defs but nothing else, perhaps using python introspection. Another option would be to pre-parse defs into a rpc client stub of just task prototypes, but that isn't as good.

    Thanks for the response and quick fix.

    -Nate

    On Aug 29, 2013, at 5:26 AM, Ask Solem Hoel [email protected] wrote:

    This is not what happens here, the length of the chain does not matter. What happens is that subtasks for tasks that are not registered falls back to using send_task, and send_task does not honor the link/link_error arguments properly.

    The fix is in master and 3.0 branches!

    —
    Reply to this email directly or view it on GitHub.

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions