运行 celery 组:其中两个任务 运行 并行以获得结果以产生第三个结果

Running celery group: where two tasks are run in parallel to get results to produce a third result

如何设置才能使相关任务运行并行(而不是顺序)以减少整体执行时间

.

@celery.task(name='master_task')
def process_chain(symbol):

   # g = group(get_latest_close_price.s(symbol), option_chain.s(symbol))
   g = group(option_chain.s(symbol), get_latest_close_price.s(symbol))

   results = g()

   with result.allow_join_result():
       data = results.get()
       data = util_transform_option_chain(data[1], data[0])

   return({'result':data})

group肯定会运行并行。 . .如果您有多个工作人员或并发性 > 1。但是,仅供参考——您可能希望将 chordgroup 结合起来,以按照您想要的方式处理结果。