我有一个芹菜任务,并行处理超大型文本文件中的每一行。我还有一个芹菜任务,需要在每一行处理后运行-它合并并处理每行的输出。因为这些是我正在处理的大量数据集,有没有什么方法可以让芹菜与生成器一起工作,而不是列表?在
def main():
header_generator = (processe.s(line) for line in file)
callback = finalize.s()
# Want to loop through header_generator and kick off tasks
chord(header_generator)(callback)
@celery.task
def process(line):
# do stuff with line, return output
return output
@celery.task
def finalize(output_generator):
# Want to loop through output_generator and process the output
for line in output_generator:
# do stuff with output
# do something to signal the completion of the file
如果这是不可能的-没有叉子芹菜-有没有其他的策略,有人可以推荐?在
在撰写本文时,传递给组和和弦的生成器将立即展开。我有一个类似的问题,所以我添加了对它的支持,并在这里创建了一个针对celery 3.x的拉请求:https://github.com/celery/celery/pull/3043
目前只支持redis。希望在《芹菜3》上映前,公关部会被合并。在
相关问题 更多 >
编程相关推荐