(self, header_result_args, body, **kwargs)
Add a ChordCounter with the expected number of results
Add a ChordCounter with the expected number of results
Add a ChordCounter with the expected number of results
def apply_chord(self, header_result_args, body, **kwargs):
        """Add a ChordCounter with the expected number of results"""
        if not isinstance(header_result_args, GroupResult):
            # Celery 5.1 provides the GroupResult args
            header_result = self.app.GroupResult(*header_result_args)
        else:
            # celery <5.1 will pass a GroupResult object
            header_result = header_result_args
        results = [r.as_tuple() for r in header_result]
        chord_size = body.get("chord_size", None) or len(results)
        data = json.dumps(results)
        ChordCounter.objects.create(
            group_id=header_result.id, sub_tasks=data, count=chord_size
        )
def apply_chord ( self , header_result_args , body , * * kwargs ) : if not isinstance ( header_result_args , GroupResult ) : # Celery 5.1 provides the GroupResult args header_result = self . app . GroupResult ( * header_result_args ) else : # celery <5.1 will pass a GroupResult object header_result = header_result_args results = [ r . as_tuple ( ) for r in header_result ] chord_size = body . get ( "chord_size" , None ) or len ( results ) data = json . dumps ( results ) ChordCounter . objects . create ( group_id = header_result . id , sub_tasks = data , count = chord_size )