votes up 3

Cannot add link to group: do that on individual tasks

Package:
celery
github stars 17847
Exception Class:
TypeError

Raise code

ly_async(self, args=None, kwargs=None, add_to_parent=True,
                    producer=None, link=None, link_error=None, **options):
        args = args if args else ()
        if link is not None:
            raise TypeError('Cannot add link to group: use a chord')
        if link_error is not None:
            raise TypeError(
                'Cannot add link to group: do that on individual tasks')
        app = self.app
        if app.conf.task_always_eager:
            return self.apply(args, kwargs, **options)
        if not self.tasks:
            return self.freeze()

        opti
🙏 Scream for help to Ukraine
Today, 14th August 2022, Russia continues bombing and firing Ukraine. Don't trust Russia, they are bombing us and brazenly lying in same time they are not doing this 😠, civilians and children are dying too! We are screaming and asking exactly you to help us, we want to survive, our families, children, older ones.
Please spread the information, and ask your governemnt to stop Russia by any means. We promise to work extrahard after survival to make the world safer place for all.

Ways to fix

votes up 2 votes down

Error code:

from celery import canvas 

#Create Signatures 
s = canvas.signature('tasks.add', args=(2, 2))
b = canvas.signature('tasks.add', args=(4,4))
#Creates a group of tasks
lazy_group = canvas.group([s, b])

lazy_group.apply_async(link_error='link of error')

Summary:

The exception is thrown in the apply_async method when calling the Group class which creates a group of tasks to be executed in parallel.

So that, when apply_async is called with parameter link_error, it will throw an error.

if link_error is not None:
  raise TypeError(
      'Cannot add link to group: do that on individual tasks')

Fix code:

from celery import canvas 

#Create Signatures 
s = canvas.signature('tasks.add', args=(2, 2))
b = canvas.signature('tasks.add', args=(4,4))
#Creates a group of tasks
lazy_group = canvas.group([s, b])

lazy_group.apply_async()
Jul 27, 2021 anonim answer
anonim 13.0k

Add a possible fix

Please authorize to post fix