Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8122333
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T05:48:15+00:00 2026-06-06T05:48:15+00:00

Question I use celery to launch task sets that look like this: I perform

  • 0

Question

I use celery to launch task sets that look like this:

  1. I perform a batch of tasks that can be run in parallel, number of tasks in this batch varies from tens to couple thousands.
  2. I aggregate results of these tasks into single answer, then do something with this answer — like store to the database, save to special result file and so on. Basically after tasks done executing I have to call function that has following signature:

    def callback(result_file_name, task_result_list): 
        #store in file
    
    
    def callback(entity_key, task_result_list):
        #store in db 
    

For now step 1. is done in Celery queue and step 2 is done outside celery:

    tasks = []

    # add taksks to tasks list 

    task_group = group()
    task_group.tasks = tasks

    result = task_group.apply_async()

    res = result.join()

    # Aggregate results 

    # Save results to file, database whatever

This approach is cumbersome since I have to stop a single thread until all tasks are performed (which can take couple of hours).

I would like to somehow move step 2 to celery also — esentially I would need to add a callback to entire taskset (as far as I know it is unsupported in Celery) or submit a task that is executed after all these subtasks.

Does anyone have idea how to do it? I use it in the django enviorment so I can store some state in the database.

To sum up my recent findings

Chords won’t do

I’cant use chords straight forwardly because chords enable me to create callbacks that look this way:

    def callback(task_result_list): 
        #store in file

there is no obvious way to pass additional parameters to callback (especially because these callbacks can’t be local functions).

Using the database either

I can store results using TaskSetMeta but this entity has no status field — so even if I would add a signal to TaskSetMeta i’d have to pool task results which could have siginificant overhead.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T05:48:16+00:00Added an answer on June 6, 2026 at 5:48 am

    Well answer was really straightforward, and I can indeed use chords — and additional parameters (like report file name and so on) must be passed as kwargs.

    Here is chord task:

    @task
    def print_and_sum(to_sum, file_name):
        print file_name
        print sum(to_sum)
        return file_name, sum(to_sum)
    

    Here is how to instantiate it:

    subtasks = [...]
    result = chord(subtasks)(print_and_sum.subtask(kwargs={'file_name' : 'report_file.csv'}))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

From the question: Proper use of this-> The answer states that -> can be
In JDBC I can use question marks for query parameters, like this: SELECT *
Similar, but different to this question : I use highlight occurrences a lot, but
The answer to another SO question was to use this SQL query: SELECT o.Id,
My question will use emails as an example, but this could apply to anything.
This question is about this topic: Vb.net all combinations Question: I use this code
Possible Duplicate: replace all occurrences in a string I found this question/answer: Use JavaScript
I'm not really used to JPA... so this is more like a basic question
Related to this question: Use with XMLVM to convert android app to iphone app
(Updated due to some confusion over my question) We use this method to generate

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.