Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

signature.link could raise AttributeError if signature is built with from_dict class method #5808

Closed
9 of 16 tasks
AnthonyDeroche opened this issue Oct 31, 2019 · 2 comments
Closed
9 of 16 tasks

Comments

@AnthonyDeroche
Copy link

AnthonyDeroche commented Oct 31, 2019

Checklist

  • I have read the relevant section in the
    contribution guide
    on reporting bugs.
  • I have checked the issues list
    for similar or identical bug reports.
  • I have checked the pull requests list
    for existing proposed fixes.
  • I have checked the commit log
    to find out if the bug was already fixed in the master branch.
  • I have included all related issues and possible duplicate issues
    in this issue (If there are none, check this box anyway).

Mandatory Debugging Information

  • I have included the output of celery -A proj report in the issue.
    (if you are not able to do this, then at least specify the Celery
    version affected).
  • I have verified that the issue exists against the master branch of Celery.
  • I have included the contents of pip freeze in the issue.
  • I have included all the versions of all the external dependencies required
    to reproduce this bug.

Optional Debugging Information

  • I have tried reproducing the issue on more than one Python version
    and/or implementation.
  • I have tried reproducing the issue on more than one message broker and/or
    result backend.
  • I have tried reproducing the issue on more than one version of the message
    broker and/or result backend.
  • I have tried reproducing the issue on more than one operating system.
  • I have tried reproducing the issue on more than one workers pool.
  • I have tried reproducing the issue with autoscaling, retries,
    ETA/Countdown & rate limits disabled.
  • I have tried reproducing the issue after downgrading
    and/or upgrading Celery and its dependencies.

Related Issues and Possible Duplicates

Related Issues

Possible Duplicates

  • None

Environment & Settings

Celery version: 4.3.0

celery report Output:

Steps to Reproduce

Required Dependencies

  • Minimal Python Version: N/A or Unknown
  • Minimal Celery Version: 4.3.0
  • Minimal Kombu Version: N/A or Unknown
  • Minimal Broker Version: N/A or Unknown
  • Minimal Result Backend Version: N/A or Unknown
  • Minimal OS and/or Kernel Version: N/A or Unknown
  • Minimal Broker Client Version: N/A or Unknown
  • Minimal Result Backend Client Version: N/A or Unknown

Python Packages

pip freeze Output:

Other Dependencies

N/A

Minimally Reproducible Test Case

Expected Behavior

The signature.link method could raise AttributeError if signature is built with from_dict class method. It should call the from_dict class method if this happens to transform the dict into a Signature instance. The call should be recursive to rebuild all sub-signatures if they are dict instances instead of Signature.

Actual Behavior

[2019-10-31 15:35:07,882: ERROR/ForkPoolWorker-8] Task cancel[5eaedd7c-9d11-42e6-88fd-952b2526ab2a] raised unexpected: AttributeError("'dict' object has no attribute 'link'")
Traceback (most recent call last):
  File "/home/[...]/python3.7/site-packages/celery/app/trace.py", line 385, in trace_task
    R = retval = fun(*args, **kwargs)
  File "/home/[...]/venv/lib/python3.7/site-packages/celery/app/trace.py", line 650, in __protected_call__
    return self.run(*args, **kwargs)
[...]
  File "/home/[...]/venv/lib/python3.7/site-packages/celery/canvas.py", line 1351, in link
    self.body.link(callback)
  File "/home/[...]/venv/lib/python3.7/site-packages/celery/canvas.py", line 1041, in link
    return self.tasks[0].link(sig)
AttributeError: 'dict' object has no attribute 'link'

I'm not an expert in Celery code byt maybe it should be possible to replace:

def link(self, sig):
        # Simply link to first task
        sig = sig.clone().set(immutable=True)
        return self.tasks[0].link(sig)

by:

def link(self, sig):
        # Simply link to first task
        sig = sig.clone().set(immutable=True)
        try:
            return self.tasks[0].link(sig)
        except AttributeError:
             return Signature.from_dict(self.tasks[0]).link(sig)

The same applies to link_error.

@auvipy
Copy link
Member

auvipy commented Oct 31, 2019

so #5297 didn't fix it fully? can you provide fix with test?

@auvipy
Copy link
Member

auvipy commented Dec 19, 2019

?

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

No branches or pull requests

2 participants