Two groups of group tasks in celery, how to make the second group of tasks wait for the completion of the first group of tasks

I need to execute two sets of tasks step by step. The subtasks in each set of tasks are executed in parallel celery, but the second group of tasks needs to wait for the first group of tasks to be completed before continuing to execute

.
from celery import group
from tasks import add

group1 = group([add.s(2, 2), add.s(4, 4),])
group2 = group([add.s(2, 2), add.s(4, 4),])

I want the tasks in groups1 to be executed concurrently first. This requires calling groups1.apply_async () of celery, but this will make the task groups1 execute asynchronously. I want group2 to wait for group1 to execute before continuing? Is there any way to do this in celery?

Mar.02,2021

first of all, let's analyze how many celery services you need.
the main thread is a must, so you need a thread main,
because group2 is executed after group1, so group1 and group2 should be Synchronize methods, executed in the same thread; and because they need to be asynchronous to the main thread, they should be executed in a celery.
so the final structure should be roughly as follows:

  1. group1 corresponds to celery1, and executes
  2. in celery1
  3. group2 corresponds to celery2, and executes
  4. in celery2
  5. there is a celery3, group1 and group2 that Synchronize should execute in the celery, and group2 should execute
  6. first.
  7. celery3 executes on main thread

roughly implement:

@app.task()
def group1():
    return group([add.s(2, 2), add.s(4, 4),])
    
@app.task()
def group2():
    return group([add.s(2, 2), add.s(4, 4),])

@app.task()
def celery3():
    result = group1.delay()
    -sharp sync group1
    result.collect()
    group2.delay()

-sharp main thread
celery3.delay()
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b395f8-4d828.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b395f8-4d828.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?